Imagine a floor made of parallel floorboards all of width L. If we drop a needle of length l at some random position on the floor, what is the likelyhood that it will land the division between two boards? This question was first posed by Georges-Louis Leclerc, Comte de Buffon. Buffon was interested in this as a problem in geometric probability, but it can also be used to estimate π.
The needles are dropped in batches
of n_trial, and the estimate
of π and its associated
statistical error (given as the 95% confidence inteval) is
given in the plot on the left. Try varying the ratio of
the needle length to the board separation, and see how the
error and success rate vary after a certain number of
steps for different ratios.
π against number of MC iterations
Zoom: click and drag, Restore: double click