Skip to main content

Posts

Showing posts from November, 2019

Calculating Pi using Monte Carlo Simulations

We can use millions of random numbers to calculate Pi. This is the Monte Carlo simulation approach and is so called because it refers to the randomness inherent in casinos for which Monte Carlo is famous. This is a neat little trick and is great exercise for A level students. We start off with a quarter circle with a radius of 1 unit. We then draw a square with an area of 1 by 1 unit that encompasses the quarter circle. We know that the area of a circle, a is Pi * r * r . Given that r=1 in this case, then a is the same as Pi . Millions of points from randomly selected pairs of x and y coordinates within the square are selected. Using Pythagoras where the magnitude of a point is given by sqrt(x*x + y*y) we can determine whether a point falls inside our outside the perimeter of the circle. The radius of the circle is 1 so if the point has a magnitude of less than 1 we know that it lies within the circle.  Based on the proportion of points that fall within the perimeter of the ci...

What is Computational Thinking?

Computational thinking is a nebulous concept that we can summarise as the ability to solve problems through the application of algorithms. The Raspberry Pi foundation consider computational thinking  to include logical thinking, decomposition, abstraction, pattern recognition, algorithm design, evaluation and organising data.  For the purposes of this article I will go with this interpretation. With the aid of concrete examples,  I will unpick each of these components in turn.   I will start with logical thinking because logic is integral to the other aspects of computational thinking. We are familiar with this way of thinking because m any puzzles and games of strategy such as chess, and solving Rubik's cube  require us to think logically.  To solve these types of problems we need to be able to think clearly and have sound reasoning.  Consider the following two statements: All computer science teachers eat cake No cake eaters cycle bicycles...