Maths · Geometric probability
Drop a plain stick onto a floor of planks. Count how often it lands across a seam. The count secretly contains π.
In 1733 the French naturalist Georges-Louis Leclerc, Comte de Buffon, posed a gambling-style puzzle: a needle falls at random on a floor ruled with parallel lines. What is the chance it touches a line? He worked it out in print in 1777, and the answer surprised everyone. It involves π, a number that seems to have nothing to do with a stick or a floor.
The board below has seams a fixed distance apart. Press a button to drop needles at random positions and angles. Amber needles cross a seam; teal ones don't. The number under π estimate is calculated only from the counts.
Running estimate against number of drops (log scale). The dashed line is the true π. Changing the length starts a fresh count.
Look at a needle of length l lying at an angle θ to the seams. Measured straight across the seams, it spans only l × |sin θ|, like the shadow of the needle on a wall. If the seams are d apart and the needle's middle lands anywhere between two of them, the needle crosses exactly when its middle is within half that span of a seam. For a needle no longer than the spacing, that gives a chance of l·|sin θ| / d.
The angle is random too, so average over every angle. The average of |sin θ| over a half-turn is 2/π, about 0.637. That is where π sneaks in: it is the average width of a spinning stick.
Try it with the slider. A needle as long as the spacing should cross about 64% of the time. A needle half that length crosses about 32%. Whatever the length, the estimate formula should drift toward 3.14.
This single needle is yours. Drag its middle to move it, or drag its tip to turn it. The bracket shows the span it covers across the seams, and the glowing band shows where its middle must sit for it to cross. Turn it so it lies along the seam and the band shrinks to nothing. Stand it across the seam and the band is at its widest.
Each drop is a coin flip with a lopsided coin, so the counts jitter. With n drops, the typical error in the estimate shrinks only like 1 / √n. To gain one more correct digit of π you need about 100 times more drops. After 1,000 drops you can usually be sure of the "3". After 100,000 you might hold 3.14.
The wobble figure above is that typical error, worked out from the maths, so you can compare it with what your own run gives.
In 1901 an Italian mathematician, Mario Lazzarini, published a result: with a needle 5/6 of the line spacing, he reported 3,408 tosses and 1,808 crossings. That gives 2 × (5/6) × 3,408 / 1,808 = 355/113 = 3.1415929, correct to six decimals. 355/113 is a famous fraction that happens to sit extremely close to π.
It is far too lucky. One crossing more or fewer would have given 3.1398 or 3.1433, and the typical error for 3,408 drops is about ±0.05. Analysts who have examined his account point out that the numbers look chosen to land on 355/113, that his intermediate results were too well behaved, and that the experiment may never have been carried out. Whether it was a joke or a fudge, it makes a good lesson about checking surprising precision.
Replay it. The button sets the needle to 5/6 of the spacing and drops 3,408 needles. Even in the best case, the single most likely crossing count (1,808) turns up only about 1 time in 73.
Nobody measures π this way. But Buffon's needle is one of the earliest problems in geometric probability, and it shows the idea behind Monte Carlo methods: use random trials to estimate a fixed number that is hard to compute directly. Those methods are now used for everything from pricing financial options to tracing particles in a reactor. A drop of a stick, a count, and a ratio: the number you want hides in the average.