« Pet peeves (part 2) | Main | Milestone »

Thursday, 18 November 2004

Comments

fv

The circle-inside-a-square was used in one of my favourite classes ever at university.

-Take a random number generator that gives numbers between 0 and 1 inclusive with as much precision as you like (the more the better though)
-Ask for two random numbers. Assign them to an (X,Y) coordinate. Ex: (0.75488, 0.17340)
-Now imagine a square going from (0,0) to (1,1). All of your randomly generated coordinates must fall within this square.
-Now imagine a circle with a centre at (0.5,0.5) with a radius of 0.5. This circle is inscribed within the square. Not all of the random coords will fall within this circle.
-You can now establish that:
(# of points in circle)/(# of points in square) =
(area of circle)/(area of square)

-You know the ratio of Circle Area to Square Area = Pi /4
-Thus, 4* percent of points in the circle gives you a value of Pi.

Using only random numbers between 0 to 1, you can get a very good value for Pi! Crazy! The longer you let it run and/or the better the precision of your random numbers, the better your estimate of Pi.

Paul

Math geeks! I'ma skeered. I'ma haid unnerneatha this here table 'til youse guys er dun.

The comments to this entry are closed.