The explanation
The average number of crossings depends only on a needle’s length, not its shape; a ring as wide as the gap always crosses exactly twice yet is π times its width around, which is how π gets into the ratio. Random throws can estimate π, but the error only shrinks like 1/√N: one more correct digit costs a hundred times more needles.
01The chance of a crossing
Let the lines be apart and the needle long. A needle is fixed by two numbers: the distance from its middle to the nearest line (uniform between and ) and its angle to the lines (uniform between and ). It crosses exactly when
Draw every possible as a rectangle: the crossings are the area under a sine curve,
With , . The π comes from averaging over the angle.
02Why the estimate is so slow
Drop needles with crossings and estimate . is binomial, with relative fluctuations of order . With the estimate has standard deviation about
About 0.024 after ten thousand needles, about 0.05 for two standard deviations: usually one decimal place. To be within 0.001 takes more than twenty million. That is the Monte Carlo method in a nutshell: it can estimate almost anything, but each extra digit costs a hundred times more.
03Buffon’s noodle
Cut the needle into many tiny pieces. Each piece crosses a line on average in proportion to its length (its direction is random), and averages add up. So for a "noodle" of any shape,
with one and the same constant . A ring of diameter meets the lines exactly twice wherever it lands, and its length is , so and . A straight needle of length crosses at most once, so its chance of crossing is . No integral needed: the π comes from the circumference of a circle.
04Lazzarini’s luck
In 1901 the Italian mathematician Lazzarini reported needles 5/6 of the gap long, 3408 thrown and 1808 crossing:
off by only 0.0000003. With the error above, about 0.05 for 3408 needles, that accuracy should be all but impossible.
The catch: to get the number thrown must be a multiple of 213 (3408 = 16 × 213), and the crossings must then match exactly. The chance of exactly 1808 crossings in 3408 throws is about 1.4%; watching as you go and stopping at the right moment, or simply making the numbers fit, makes it far easier. Statisticians often cite it as an example of choosing when to stop.
Questions
What if the needle is longer than the gap?
Then one needle can cross two lines at once, and the chance of crossing is no longer $2l/(\pi d)$. But the average number of crossings is still $2l/(\pi d)$ (the noodle argument does not need $l\le d$), so counting crossings rather than needles still estimates π. The stage keeps needles no longer than the gap.
Are the needles on the stage really random?
Free play uses fixed seeds hashed per needle, a new seed each time you clear; the story uses one fixed seed, so it plays the same every time and ten thousand needles always give 3.1546. Statistically neither can be told apart from true randomness here.
Is there a faster random way to estimate π?
Scatter points in a square and count the share inside the inscribed circle (π/4): the error also shrinks like $1/\sqrt N$, just with a smaller constant. Every dice-throwing method shares that $1/\sqrt N$ limit; to actually compute π, people use series that converge extremely fast.
The syllabus side
Related curves
Sources: Buffon’s needle problem — Wikipedia · Buffon’s noodle — Wikipedia