◄ WORLD II · THE FOLDTHE OCHO · blue builds │ the machine │ red breaks

THE MONTE CARLO

You cannot integrate the circle by hand? Then throw dice at it. Rain random darts on the unit square, count how many land inside the quarter circle, and the ratio is π/4 — so π ≈ 4·inside/total, with no formula, no calculus, only counting. The estimate is real, live, and honest: it wobbles toward π and the error shrinks like 1/√n. The blue team builds and defends it; the red team tries to break it.

source N. Metropolis & S. Ulam, The Monte Carlo Method, J. Amer. Statist. Assoc. 44(247), 335–341 (1949) — archive.org/details/sim_journal-of-the-american-statistical-association_1949-09_44_247. Rendered, not quoted.

◧ blue team · builds & defends
3

THE MODEL — throw & count

The whole machine is one idea. The quarter circle of radius 1 has area π/4; the surrounding unit square has area 1. Drop a uniform random point (x,y) in the square — the chance it lands inside is exactly the area ratio, π/4. So:

π ≈ 4 · (inside) / (total)

A point is inside when x²+y² ≤ 1 — one multiply, one compare. No calculus is ever performed. For the current run:

quantityvalue
5

THE LINEAGE — from Ulam's cards AVAN

Los Alamos, 1946: Stanislaw Ulam, laid up with illness, plays solitaire and wonders what fraction of games win. The combinatorics defeat him — so he imagines just dealing many hands and counting. With von Neumann and Metropolis he turns it on the neutron-diffusion integrals no one could solve by pen.

The 1949 paper names and systematizes it. Draw samples, tally outcomes — the same move sits under every simulation since, and its correlated cousin, the Markov chain, turns independent darts into MCMC. Each sphere is the next one's premise.

7

THE WITNESS live

The blue team's live check: re-run the estimator over a ladder of sample sizes and confirm it converges to π and the error falls like 1/√n. If red tampers with the test, this badge is where it shows.

▼ the machine ▼
4

DATA IN — the inputs in ↓

The estimator eats exactly three things: a seed (fixes the pseudo-random stream so every run is reproducible), a count n of darts to throw, and the rule of inside — the unit quarter circle x²+y² ≤ 1 living in the unit square [0,1]×[0,1].

Randomness comes from a fixed-seed mulberry32 PRNG returning values in [0,1) — deterministic, so the self-check is repeatable. Feed these to the panel below.

▼   throw the darts   ▼
0

▣ THE PANEL — the engine LIT

Each dot is one dart: inside the quarter circle or outside. Up to 3,000 dots are drawn; the estimate uses all n.

≈ π
true π = 3.1415927
inside / total =
absolute error =
theoretical 1σ (1.6423/√n) =

Change n or the seed — the estimate is counted from the darts on the spot, never looked up.

▼   the count becomes an estimate   ▼
8

DATA OUT — the result out ↓

What the machine produces, proven: a live estimate of π from nothing but counted darts, whose error shrinks like 1/√n — quadruple the darts, roughly halve the error. It is a statistical estimate, never exact; the panel shows both the value and its error bar.

The blue team's witness (left) confirms convergence and scaling live; the red team (right) tries to make it converge to the wrong number.

red team · attacks & breaks ◨
1

THE ADVERSARY

WALL Monte Carlo is slow. Error falls only as 1/√n, so each extra decimal digit of π costs 100× more darts. For a 2-D integral like this, classical quadrature (Simpson, Gauss) reaches machine precision in a few thousand evaluations — Monte Carlo never will.

Its win comes only in high dimensions, where grid methods die of the curse of dimensionality and MC's 1/√n is independent of dimension. And the "random" darts are pseudo-random: a poor generator with hidden correlations biases the answer, which is why the seed and PRNG are named and fixed here, not hand-waved.

2

THE GRAVEYARD

"More darts always give a better estimate." Cut. Only in expectation. A single run can worsen with more darts — try seed 20902 at n=100 vs n=1000 and watch the error rise before it falls.

"Monte Carlo computes π exactly." Cut. It returns a random estimate with an error bar; it is never exact and never terminates at the true value.

"The 1949 paper invented the method." Kept, corrected. It named and systematized it (Ulam's idea, 1946); random sampling for integrals goes back to Buffon's needle, 1777.

6

THE TAMPER — break it

The red team's move: change the "inside" test from radius 1 to radius 2 (x²+y² ≤ 4). Now every dart in the unit square counts as inside, so the estimate marches to 4, not π. The blue team's witness (window 7) is watching.

Widen the circle and the count is wrong on purpose — the estimate converges to 4, the witness recomputes, disagrees with π, and turns red. Nothing is faked; the attack is real and it is caught.