Statistics

Monte Carlo

Throw darts at random into a square with a circle inside it. The fraction that land in the circle is π/4, so counting darts estimates π. It converges slowly, but it needs no calculus at all.

Darts thrown0
Inside circle0
Estimate of π
Error

What to observe

  1. The square has area 4 and the circle area π, so a random dart lands inside with probability π/4. Multiply the hit fraction by 4 and you have an estimate of π, no formula for the circle needed.
  2. Watch the convergence plot settle toward the dashed π line. It wobbles a lot early on, then tightens. The error shrinks like 1/√n: a hundred times more darts buys only one more digit.
  3. That slow square-root rate is the price of pure randomness, and exactly why Monte Carlo shines only when the problem is too high-dimensional for anything else.

Shortcuts: space run/pause · s step · r reset · f fullscreen