No. 025 · Chance

Throw 10,000 random darts to find π

10,000 random darts, 7,853 inside the circle: 4 × 7,853 / 10,000 = 3.1412.

π ≈ 4 × inside / thrown

Draw a circle inside a square that just fits it. Throw darts at the square completely at random. Some land inside the circle, some in the corners.

Why it finds π

If the circle has radius 1, the square has sides of 2:

ShapeArea
square4
circleπ

So a random dart lands inside the circle with chance π/4. Count the darts that do, divide by all the darts, and multiply by 4:

π ≈ 4 × inside / thrown

This run

The video throws 10,000 darts, the first 20 slowly. 7,853 land inside, so the estimate is 4 × 7,853 / 10,000 = 3.1412. True π is 3.14159…, so it's off by about 0.0004.

That's a lucky run. With 10,000 darts the estimate is typically off by about 0.016, and the video uses seed 4, the first of the seeds it tried whose estimate landed within 0.001 of π. The error shrinks with the square root of the number of darts: to get one more correct digit, you need about 100 times as many darts.

Using random samples to estimate a number is called the Monte Carlo method, named after the casino. It was developed in the 1940s for work on the first nuclear weapons, and is now used everywhere from physics to finance.

Part of Chance (5 videos): Random steps that add up to something predictable.

Use this picture

SVGJPG

Free to reuse, also commercially, under CC BY 4.0. Credit “What Math Means” with a link to whatmathmeans.dev/v/10000-darts-find-pi.