Needle Pi
Buffon's needle: drop random needles, count line crossings, estimate π.
π ≈ 2 · L · N / (d · C) = 2 · 1.00 · 0 / (1.00 · 0) = —
Convergence
Running estimate vs. drops. Dotted line marks the true π. The visual band is roughly ±1.96/√C, the natural wobble for C crossings.
How it works
Drop needles of length L at random onto lines spaced d apart (with L ≤ d). A needle crosses a line when its centre falls within (L/2)·|sin θ| of a line, where θ is its angle. Averaged over all angles that probability is 2L/(πd), so:
π ≈ 2 · L · N / (d · C) N = drops, C = crossings
The estimate only exists once at least one crossing has happened — before that the app shows an em dash instead of dividing by zero. Error shrinks slowly, roughly like 1/√N.
Every run is driven by a small seedable PRNG (mulberry32). The same seed, length and
spacing always reproduce the same sequence of needles, so results are reproducible.