Coin Flip Statistics Simulator — A Hands-On Tool for the Probability Classroom

Coin Flip Statistics Simulator — A Hands-On Tool for the Probability Classroom
Coin Flip Statistics Simulator — A Hands-On Tool for the Probability Classroom

This page is built for the probability classroom — but whether you're a teacher or just curious, you can watch probability happen instead of reading about it. Rather than studying the Law of Large Numbers or the binomial distribution in the abstract, you (or your students) can see them unfold in real time by running tens of thousands of virtual coin flips with a single click. Four interactive simulators below explore convergence, random walks, distributions, and streaks — the four ideas every introductory probability lesson must cover.

No installation, no spreadsheet — just open this page on any device and start exploring. Each simulator is self-contained, mobile-friendly, and works in both light and dark mode.

1. The Law of Large Numbers

As you flip a coin more and more times, the observed proportion of heads should converge toward the true probability. Try it: type the number of flips, then run the simulation. Watch the line bounce wildly at first, then settle ever closer to the dashed reference line.

Heads ?
Tails ?
Observed ?
|p̂ − p| ?

For discussion: Try 100 flips, then 10,000. How does the gap between observed and theoretical probability change? Now try a biased coin (p = 0.7). Does it still converge? You can also see this convergence on the site's actual data on the Site Statistics page.

2. Random Walk — When the Difference Drifts

The Law of Large Numbers says the proportion of heads will converge to 0.5. A common mistake is to assume the count of heads minus tails also converges to zero — but it doesn't. The gap actually drifts further from zero, just slowly enough that the proportion still settles. This kind of trajectory is called a random walk.

Final difference ?
Std. deviation (σ = √n) ?
Final pos inside ±2σ ?

How big does the gap typically get? The typical gap is about 8 after 100 flips and about 80 after 10,000. The chart's grey envelope marks the wider 95% zone — the ±2σ band, where σ = √n for the heads-minus-tails count (about ±20 after 100 flips) — which a fair walk stays inside about 95% of the time. The proportion shrinks because the denominator grows faster than the gap — not because the gap itself shrinks.

For discussion: Run the walk a few times. Does it always return to zero? Why does the “gambler's fallacy” — the belief that a long streak of heads must be followed by tails to “balance out” — contradict what this graph shows? You can also see this concept applied to the site's live data on the Site Statistics page.

3. The Bell Curve in Action

If you flip 100 coins and count the heads, you'll usually get something close to 50 — but rarely exactly 50. Repeat the experiment many times and the distribution of "heads counts" forms the familiar bell shape: the binomial distribution. The simulator runs many independent experiments at once and overlays the theoretical curve so students can see how empirical results approximate it.

Mean ?
Std. dev. ?
Theoretical mean ?
Theoretical SD ?

For discussion: The theoretical mean of n flips is n·p, and the standard deviation is √(n·p·(1−p)). Compare these with the observed values. Why does the empirical mean almost match the theoretical, but the standard deviation can drift slightly?

4. Streaks and Runs

Many students believe that a long run of heads — say, eight in a row — is evidence of bias. In fact, with 1,000 fair flips, the expected longest streak is around 9 (the log₂(n) − 1 rule of thumb). Long runs are a feature of randomness, not a bug. This simulator measures the longest streak in each of your experiments and shows the distribution.

Avg. longest streak ?
Theoretical estimate ?
Max observed ?

The theoretical estimate uses the approximation E[Ln] ≈ log₂(n) − 1, valid for large n with a fair coin. The actual distribution is right-skewed because the longest streak can occasionally be much greater than the mean.

For discussion: If a student tells you a "lucky streak" of 7 heads proves a coin is biased, what does this simulator tell you? Run 5 experiments at n = 1000 — how often does the longest streak hit 12 or more?

Ideas for the Classroom

Three lesson ideas you can build around this page:

  • Predict-then-test. Before running each simulator, have students write down their predictions on paper. For Simulator 1, ask "How close to 50% do you expect after 200 flips? After 5,000?" The visual contrast between expectation and reality is the lesson.
  • Sample-size matters. Run Simulator 1 several times at n = 100, then several times at n = 10,000. Notice how the variation in the final shrinks. This is the practical meaning of the Law of Large Numbers — and the reason large studies are more trustworthy.
  • The gambler's fallacy debate. Use Simulator 4 to show that long streaks happen all the time in random sequences. Discuss why people misinterpret streaks as evidence of bias (or "due" outcomes after a long run).

Curriculum alignment

This page supports the following common topics in introductory statistics:

  • Probability of independent events
  • Empirical vs theoretical probability
  • Law of Large Numbers
  • Binomial distribution and its normal approximation
  • Standard deviation and variance
  • Sampling variability
  • Runs / streak theory (intuition for the gambler's fallacy)

Going further

Each simulator runs in your browser, so the math is fully transparent. Open your browser's developer tools and inspect the page source — students who want to learn programming can read the simulation code and modify it. The flips themselves use the browser's built-in crypto.getRandomValues() — the same cryptographically-strong randomness the live site uses for a single coin toss — so the numbers you see come from genuine high-quality randomness, not a toy generator.

Once your students have explored these four simulators, they can apply the same statistical tests to live data: the Site Statistics page runs a chi-squared test and Z-test on every coin flip ever performed on this site, with confidence intervals and a verdict on whether the coin is statistically fair. They can also see the same Law of Large Numbers and Random Walk visualizations applied to that real-world dataset.

Visit the main Flip a Coin page to generate fresh flips that contribute to the global experiment — turning abstract theory into something you can watch grow.

References

  • Schilling, M. F. (1990). "The Longest Run of Heads." The College Mathematics Journal, 21(3), 196–207. jstor.org/stable/2686886 — classic treatment of longest-streak distributions for fair coins.
  • Grinstead, C. M. & Snell, J. L. (1997). Introduction to Probability. American Mathematical Society. chance.dartmouth.edu — free undergraduate text covering LLN, binomial distribution, and random walks.
  • Diaconis, P., Holmes, S., & Montgomery, R. (2007). "Dynamical Bias in the Coin Toss." SIAM Review, 49(2), 211–235. statweb.stanford.edu (PDF) — physical (non-RNG) sources of coin-flip bias — background for the simulator's discussion of why simulated flips are fairer than thumb-flicked physical coins.

Frequently Asked Questions

What is the Law of Large Numbers in simple terms?
As you flip a coin more and more times, the percentage of heads gets closer and closer to 50%. Short-term results swing wildly; long-term proportions settle.
Does a long streak of heads mean the coin is biased?
No. With 1,000 fair flips, the expected longest streak is around 9 in a row. Long runs are a natural feature of randomness — the simulator's streak tool lets you see this for yourself.
What random source do these simulators use?
The browser's built-in crypto.getRandomValues() — the same cryptographic-quality randomness the live site uses for real coin flips. The numbers are not a toy generator.
Can I use these simulators in my classroom?
Yes — that's what the page is built for. No installation or spreadsheet needed; every simulator runs in the browser on any device, and the page includes ready-made lesson ideas and discussion prompts.

Share this link via

Or copy link