Buffon’s needle problem is a question first posed in the 18th century by Georges-Louis Leclerc, Comte de Buffon:
This problem can be used to estimate ?. If we set the nail size and the line distance = 1, the estimator can be calculated by:
Because throwing 80.000 needles can be annoying, I created an implementation in R. The result took over two hours to render an is attached to this post. It was generated by saving multiple GIF files and combining them to a movie. Red needles are hits, the heading represents the current approximation of ?.
After loading the function you can start a simulation by typing:
The following command will create one simulation with 100 needles: And here’s the function:
For more information on R and what to do with it visit: www.r-bloggers.com