A web search for Monte Carlo method Ulam Metropolis pi estimation pulls together the history this sketch depends on: the standard account that Stanisław Ulam and Nicholas Metropolis gave the method its casino name in the 1940s, and the familiar textbook demonstration that a circle inside a square turns random sampling into an estimate of π because the area ratio is fixed at π/4. The idea still feels fresh because it converts a geometric constant into a patience test. Each trial asks whether a point landed inside the circle or outside it.
The full artifact page and the raw gallery sketch make that reduction satisfyingly literal. Cyan dots accumulate inside the circle, red dots miss, and the estimate in the HUD jitters early because small samples are noisy, then settles as the counts grow. The early jitter keeps the finite mess on screen while repetition makes the ratio harder to bully around.
const isIn = dx*dx + dy*dy <= r*r;
if (isIn) inside++;
total++;
const approx = 4 * inside / total;
const err = Math.abs(approx - Math.PI);
That snippet contains the entire estimator. The code counts hits, counts trials, and rescales the ratio. The sketch makes randomness cumulative and inspectable. Each dot is one trial, and each trial updates the estimate.
Monte Carlo
A probability sketch that estimates π by throwing random points into a square and asking how many fall inside the inscribed circle.
View artifact → Open gallery sketch →