Throw Darts to Find Pi
Random guesses can find exact-looking answers. Throw darts at a circle, then beat a puzzle by simulating it.
Throw some darts! Nobody aims, yet counting the ones inside the circle will reveal pi.
A car is behind one door, goats behind the others. Pick a door!
By hand: stay
0 / 0
By hand: switch
0 / 0
Rounds
0
Challenges
Throw 1,000 darts and see a guess that is close to pi.
Keep throwing until your guess is within 0.03 of real pi (with at least 1,000 darts).
Play Monty Hall by hand: try at least 3 rounds that stay and 3 that switch.
Run 10,000 games of always-stay and of always-switch. Which one wins about twice as often?
What just happened?
- Random darts know nothing about circles, yet counting how many land inside gives pi. Area ratio times 4.
- Few darts, wobbly guess. More darts, steadier guess. But to get 10 times more accurate you need about 100 times more darts.
- In Monty Hall, your first pick wins only 1 time in 3, and that does not change when the host opens a goat door. So switching wins 2 times in 3.
- When thinking is confusing, simulate it! Running the game thousands of times is a real way to find an answer.
For grown-ups: what's really going on
Monte Carlo methods estimate a quantity by random sampling. For pi: draw (x, y) uniform on the unit square; P(x² + y² ≤ 1) = π/4, so π ≈ 4 · hits / n.
- Each dart is a Bernoulli trial with
p = π/4, so the estimate has standard deviation4 √(p(1−p) / n) ≈ 1.64 / √n. That is the 1/√n error rate: it does not depend on dimension, which is why Monte Carlo is used for hard high-dimensional integrals (physics, graphics, finance, reinforcement learning rollouts). - The chart averages 40 independent runs per size, so the orange 1 ÷ √n guide and the blue measured curve are parallel lines on log-log axes (slope −1/2).
- Monty Hall: P(car behind your first pick) = 1/3. The host always opens a goat door that you did not pick, which gives no new information about your pick, so the other closed door carries the remaining 2/3. The simulation here follows the exact rules, including the host choosing randomly when two goat doors are available.
- The random number generator is a seeded pseudo-random generator (mulberry32), so a run is reproducible.
Further reading: Metropolis and Ulam (1949), The Monte Carlo Method · Khan Academy, Monty Hall problem.