🩡 Buffon's Needle
About this simulation
In 1733, Georges-Louis Leclerc, Comte de Buffon, posed a question: if a needle is dropped at random onto a floor ruled with parallel lines, what is the probability it crosses a line? The surprising answer involves π, making this one of the oldest problems in geometric probability and one of the earliest known Monte Carlo experiments — centuries before the term existed.
How it works
- Parallel lines are ruled a fixed distance d apart, with the needle length l no greater than d.
- Each dropped needle gets a uniformly random centre position (modulo the line spacing) and a uniformly random angle θ between 0 and π.
- A needle crosses a line if half its length projected onto the vertical, (l/2)·sin(θ), reaches at least as far as the needle's distance to the nearest line.
- The theoretical crossing probability is P = 2l/(πd), so rearranging and using the observed crossing count gives an estimate of π.
Key equations
P(crossing) = 2l / (πd)
π ≈ (2·l·N) / (d·C) — l = needle length, d = line spacing, N = needles dropped, C = crossings observed. The estimate improves, on average, as N grows.
Controls
- Needle length l / spacing d — sets the needle length relative to the fixed line spacing (must stay ≤ 1).
- Drop rate — how many needles are dropped per animation frame.
- Pause / Reset — freeze the simulation or clear all dropped needles and start again.
Did you know?
In 1901 the Italian mathematician Mario Lazzarini claimed to estimate π to six digits using Buffon's needle with only 3,408 throws — a suspiciously lucky result that many statisticians believe was tuned by stopping at a favourable moment, since the natural convergence rate of the method is far too slow to justify such precision.