Labs · Randomness

Monte Carlo π

Monte Carlo π simulation

Randomness can compute things. Throw darts uniformly at a square that contains a circle. The fraction that lands inside approaches the ratio of the areas, π/4, so π ≈ 4 × inside / total.

This is a Monte Carlo method. The error shrinks only like 1/√n: 100× more darts buy one extra correct digit. The chart shows the estimate wobbling toward π.

Set the darts per frame to 1 and watch how noisy the first estimates are.

Controls

Evolved from Distributions.

Evolved into Buffon's Needle.