🪡 Buffon's Needle
Drop random needles onto a floor ruled with parallel lines and watch π emerge from the crossing probability. An interactive recreation of Buffon's classic 18th-century probability experiment.
About this simulation
This tool recreates Buffon's needle, the 1733 probability puzzle in which needles of length l are dropped onto a floor ruled with parallel lines spaced d apart. Each needle lands at a uniformly random position and angle, and whether it crosses a line depends on simple trigonometry. Because the theoretical crossing probability is 2l/(πd), tallying dropped needles against crossings and rearranging the formula produces a live, ever-refining estimate of π.
🔬 What it shows
Each needle gets a random centre position y modulo d and a random angle θ in [0, π). It crosses a line when (l/2)·sin(θ) is at least the needle centre's distance to the nearest ruled line. Since P(crossing) = 2l/(πd), the running ratio of needles to crossings gives π ≈ (2·l·N)/(d·C).
🎮 How to use
Adjust the needle-length slider to change l relative to the fixed line spacing d (kept ≤ d), and the drop-rate slider to control how many needles fall per frame. Use Pause to freeze the animation and Reset to clear all needles and begin a fresh trial. The stats box tracks needles dropped, crossings and the current π estimate with its error.
💡 Did you know?
Buffon's needle is considered one of the very first Monte Carlo methods, predating the formal theory by roughly two centuries. It shows that a purely geometric probability experiment — with no explicit circles at all — can still reveal π, because the sine function connecting angle to crossing distance carries π implicitly.
Frequently asked questions
What is Buffon's needle problem?
Buffon's needle problem, posed in 1733, asks: if a needle of length l is dropped at random onto a floor ruled with parallel lines spaced d apart, what is the probability the needle crosses a line? When l ≤ d, the answer is P = 2l/(πd), linking a simple physical experiment directly to π.
How does dropping needles let you estimate π?
Since the crossing probability equals 2l/(πd), observing the fraction of dropped needles that cross a line and rearranging the formula isolates π: π ≈ (2·l·N)/(d·C), where N is the number of needles dropped and C is the number of crossings. More drops produce a more reliable estimate.
Why does the needle length matter?
The needle length l relative to the line spacing d sets the base crossing probability. Longer needles (closer to l = d) cross lines more often, giving more crossing events per drop and a statistically more stable estimate for the same number of throws, though the underlying formula remains valid for any l ≤ d.
Is Buffon's needle a true Monte Carlo method?
Yes. It uses repeated random trials — random needle position and angle — to estimate a mathematical constant from an observed frequency, which is exactly the definition of a Monte Carlo method. It predates the formal Monte Carlo technique developed at Los Alamos in the 1940s by roughly two centuries.
Why does the estimate converge slowly?
Like all Monte Carlo estimates, Buffon's needle converges at a rate proportional to 1/√N, so quadrupling the number of drops only halves the typical error. Reaching high precision this way requires an enormous number of needles, which is why claimed high-precision historical results are viewed with scepticism.
Drop random needles onto a floor ruled with parallel lines and watch pi emerge from the crossing probability, recreating Buffon's classic 18th-century experiment.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install