Monte Carlo π

Computer Science: Concepts & Explorations
David Reed

This Web page performs two different Monte Carlo simulations that can be used to approximate the value of π.

Random darts: Consider throwing darts at a square dart board that has a circle inscribed in it. If the darts are completly random (i.e., equally likely to land anywhere in the square), then the ratio (darts inside the inscribed circle)/(total darts in the square) is an approximation of (area of circle)/(area of square) = π*radius2/(2*radius)2 = π/4. Therefore, π ≈ 4*(darts in circle)/(total darts in square).

Random needles: Consider dropping needles on a table top that has vertical lines drawn on it, where the distance between the lines is twice the length of the needles. French mathematician Georges-Louis Leclerc, Comte de Buffon proved that a randomly dropped needle (i.e., one that is equally likely to land anywhere, at any angle) has a 1/π chance of landing on a line. Thus, π ≈ (total needles on table) / (needles crossing a line).


Your browser does not support the HTML5 canvas tag. Number of darts to generate:    




Number inside the circle: 0
Total number of darts: 0


 
 
Your browser does not support the HTML5 canvas tag. Number of needles to generate:    




Number crossing a line: 0
Total number of needles: 0