Buffon's Needle — Monte Carlo π

Drop random needles on parallel lines. Estimate π from the crossing frequency.
Interactive HTML (no libraries)

Controls

Stats

Throws n0
Crossings k0
Empirical rate p̂ = k/n—
Theoretical p(L,D)—
π̂ from p̂—
95% CI for π̂ (delta)—
|π̂ − π|—
For L ≤ D: p = 2L/(πD) ⇒ π̂ = 2L/(Dp̂). For L > D the general Buffon formula is used. Confidence interval via delta method for g(p)=C/p, where C depends on L/D.
Click canvas to toggle Start/Pause