Some Random Thoughts for Pi Day
Ken Osborn © 2012
I'll leave the first two questions to others, but a simple Excel program to generate random numbers can be used to produce an estimate of Pi. Consider a circle with a diameter of 2 feet. The radius will then be 1 foot and the area Pi square feet. If it is enclosed inside a square, the square will have sides of 2 feet with an area of 4 square feet. The ratio of areas of circle to square will then be Pi/4. Suppose you now throw darts at a dart board with a diameter of 2 feet enclosed in a square. The ratio of hits inside the board divided by the number of tosses inside the square will be the same as the ratio of areas.
Write a program to generate two sets of random numbers bounded by zero and one (0,1). These will be the coordinates for a point to be tested. If the distance of the ordered pair to the center is less than one it is inside the circle. If it exceeds one it is outside the circle. Below is a screen shot from one run of the program. The blue line is the running estimate of Pi for the specified number of dart tosses. The purple line is the error calculated as the difference between the estimate and value of Pi to 2 digits (3.14)
If you'd like to try estimating Pi using the program, you can at Estimating Pi Spreadsheet
No comments:
Post a Comment