Coin Flipper

Flip a coin up to 10,000 times with adjustable bias. Track heads/tails counts, streaks, z-scores, running percentages, and alternation rates.

Coin Flipper

50 for fair coin, adjust for bias
H Count
4 (40.0%)
Expected: 5.0 ยฑ 1.6
T Count
6 (60.0%)
Expected: 5.0
Longest H Streak
3
Expected ~2.3 for 10 flips
Longest T Streak
3
Expected ~2.3
Z-Score
-0.632
Within normal range for a fair coin
Alternation Rate
44.4%
4 changes in 9 transitions (expected ~50%)
TTTHTHHHTT

Running Heads Percentage

After Flip #Cumulative H%Deviation from 50%Visual
10.0%-50.0%
20.0%-50.0%
30.0%-50.0%
425.0%-25.0%
520.0%-30.0%
633.3%-16.7%
742.9%-7.1%
850.0%0.0%
944.4%-5.6%
1040.0%-10.0%

Probability Reference

EventProbabilityExpected in 10 flips
Single H50.0%5.0
3 H in a row12.50%1.3
5 H in a row3.125%0.31
10 H in a row0.09766%0.010
Planning notes, formulas, and examples

About the Coin Flipper

Need a quick decision? Flip a coin. Want to understand probability? Flip ten thousand. Our Coin Flipper does both โ€” from a single fair coin toss to massive simulations with adjustable bias, streaks analysis, z-score fairness testing, and a running percentage tracker that visualizes the law of large numbers in real time.

Every simulation shows the full sequence with color-coded results, so you can visually spot patterns (and then learn why those patterns don't actually mean anything in a random process). The z-score output tells you whether your results deviate significantly from expectations โ€” useful for testing suspect coins or validating random number generators.

Whether you're settling a bet, teaching probability in a classroom, or running Monte Carlo experiments, This calculator transforms the simplest random event into a rich statistical experience. Switch between Heads/Tails, 1/0, or Win/Lose labels to match your use case.

When This Page Helps

A physical coin flip is limited to one toss at a time with no record-keeping. Our digital flipper provides instant batch simulations, automatic statistical analysis, and visual sequence displays. The z-score output gives you a rigorous fairness test that would be impractical to compute by hand.

For educators, the running percentage table demonstrates the law of large numbers beautifully โ€” early flips show wild swings, but the percentage converges toward the true probability as sample size grows. This single visualization teaches more about statistics than a chapter of textbook theory.

How to Use the Inputs

  1. Choose the number of flips (1 to 10,000) or pick a preset.
  2. Set the heads probability โ€” 50% for a fair coin, higher or lower for bias.
  3. Select your preferred labeling (Heads/Tails, 1/0, or Win/Lose).
  4. Choose whether to display the full flip sequence.
  5. Click Flip to simulate the coin tosses.
  6. Review counts, streaks, z-score, and alternation rate in the output cards.
  7. Scroll down for the running percentage table and probability reference.
Formula used
For N flips with probability p of heads: Expected heads = Np. Standard deviation = โˆš(Np(1-p)). Z-score = (observed - expected) / ฯƒ. A |z| > 1.96 suggests the coin may be biased at the 5% significance level.

Example Calculation

Result: Heads: 53 (53%), Tails: 47 (47%), Longest H streak: 6, Z-score: 0.60

53 heads in 100 fair flips gives a z-score of 0.60, well within the normal range (|z| < 1.96). The longest streak of 6 matches the expected ~6.6.

Tips & Best Practices

  • Flip 1000+ coins to see the running percentage converge toward the true heads probability.
  • Try 70% heads probability and see how quickly the z-score detects the bias.
  • Use Win/Lose labels to simulate binary outcomes like sales conversions or game wins.
  • An alternation rate much higher than 50% suggests non-random switching behavior.
  • For classroom demos, compare 10 flips (wild variation) vs 10,000 flips (tight convergence).
  • The z-score threshold of 1.96 corresponds to the classic 95% confidence level.

The Law of Large Numbers

The coin flipper's running percentage table illustrates one of probability's most fundamental theorems. After just 10 flips, the observed heads percentage might be anywhere from 20% to 80%. After 100 flips, it typically narrows to 40-60%. After 10,000 flips, you'll almost always see 49-51%. The sample proportion converges to the true probability โ€” this is the law of large numbers in action.

This convergence is why casinos are profitable: individual gamblers experience wild swings, but the house edge compounds over millions of bets to produce reliable profit. The same principle underlies insurance, polling, and quality control.

Testing Coin Fairness

If you suspect a physical coin is biased, you need a statistical test. Flip it N times, count heads H, and compute z = (H - N/2) / โˆš(N/4). If |z| > 1.96, you can reject fairness at the 5% significance level. For practical detection of small biases (1-2%), you need several thousand flips.

Real coins do have slight biases โ€” a 2007 Stanford study found that coins are about 51% likely to land on the same face they started on, due to precession during the flip. This 1% bias is undetectable in fewer than about 10,000 flips.

Coin Flips in Computer Science

The simple binary random variable is foundational to computer science. Randomized algorithms, hash functions, load balancers, and cryptographic protocols all build on coin-flip-like primitives. The Bernoulli distribution (single coin flip) generates the Binomial distribution (N flips), which connects to the Normal distribution via the central limit theorem.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • It uses Math.random(), a pseudorandom number generator that's more than sufficient for casual use, simulations, and teaching. For cryptographic purposes, use window.crypto instead.