Probability & Uncertainty

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.

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?

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 deviation 4 √(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.