01 try one run
your turnEach click is a random flip. The coin is a visual,
not a physics simulation.
02 let your browser do the work
Your coin flips will draw this line.
teal: your estimate gold: π, for comparison only
a coin. a stopping rule. a very slow calculator.
Flip until heads first outnumber tails.
Save the fraction of heads. Start over.
Average those fractions, then multiply by 4.
Each click is a random flip. The coin is a visual,
not a physics simulation.
Your coin flips will draw this line.
teal: your estimate gold: π, for comparison only
Some runs take a very, very long time. We put a limit on each one. If it hasn’t finished, we include a range for its eventual result instead of throwing it away.
At the first heads lead, heads exceed tails by exactly one. After n flips, the head fraction is ½ + 1/(2n). If a run hits its limit k, its eventual fraction lies between ½ and ½ + 1/[2(k+1)].
The displayed estimate uses the lower ends of those ranges. The unfinished-run range is separate from the approximate 95% sampling interval. A small sample, an early stop, or a very low flip limit can make the estimate uninformative. This is a numerical illustration of a theorem, not a proof.
Everything runs locally in a background worker. Bulk runs use a seeded Mulberry32 pseudorandom generator, not the NumPy generator used for our original post. Different generators produce different samples.
read the simulation source ↓