Learning Scientific Programming with Python (2nd edition)
P6.6.2: Buffon's needle
Question P6.6.2
A classic problem, first posed by Georges-Louis Leclerc, Comte de Buffon, can be stated as follows:
Given a plane ruled with parallel lines a distance $d$ apart, what is the probability that a needle of length $l \le d$ dropped at random onto the plane will cross a line?
The problem can be solved analytically, yielding the answer $2l/\pi d$; show that this solution is given approximately for the case $l=d$ using a random simulation (Monte Carlo) method: that is, by simulating the experiment with a large number of random orientations of the needle.
A related problem involves dropping a circular coin of radius $a$ onto a floor consisting of square tiles, each of side $d$. Show that the probability of a coin crossing a tile edge is $1 - (d-2a)^2/d^2$ and confirm it with a Monte Carlo simulation.