Skip to content
Toolcroft

Coin Flipper

Random Generators

Flip 1–10 virtual coins, track session results, and explore weighted heads probabilities. Random results use the browser’s Web Crypto API.

Click Flip (or press Space) to flip a coin.

How to use this tool

  1. Set the coin count. Choose 1–10 coins to flip at once. Each flip is independent.
  2. Optionally adjust the weight. Enable the weighted coin toggle and drag the slider to change the probability of heads. Leave at 50% for a standard fair coin.
  3. Flip. Click the Flip button (or press Space). The result appears with a brief animation.
  4. Review history and stats. Each flip is recorded below. Running totals show the cumulative heads/tails percentage for the session. Click Reset to clear history.

How this coin flipper works

Every flip uses crypto.getRandomValues, the browser's cryptographically secure random number generator backed by the operating system's entropy pool. A 32-bit value is drawn and mapped to a probability in [0, 1). If that value is less than the heads probability (0.5 for a fair coin), the result is heads; otherwise tails. This avoids the weak distribution of Math.random() entirely.

Fair coins and the law of large numbers

With the weighted option off, each virtual coin uses a 50% heads probability and a 50% tails probability. Short sequences regularly show streaks; that's normal probability, not a bug. Over many flips, the observed heads share tends toward its expected 50%. This is the law of large numbers in action. The session chart compares the observed share with the expected share for the probabilities used in each round.

Weighted coins for probability experiments

Enable the Weighted coin option to set a custom heads probability between 0% and 100%. At a constant 70%, the expected heads share is 70%, though a small sample can differ. If the probability changes between rounds, the chart's expected share is the coin-count-weighted mean: sum(nᵢ × pᵢ) / sum(nᵢ), where nᵢ is the number of coins and pᵢ the heads probability in round i. The dashed trace uses the probabilities recorded with each round, so changing the slider does not rewrite earlier expectations. Weighted mode is for probability demonstrations, not decisions.

Flipping multiple coins

Select 2–10 coins to flip simultaneously. Each coin is drawn independently from a separate random value, so there is no correlation between results. The combined heads and tails count for each flip round is logged to the history and tallied in the session stats.

The gambler's fallacy

The gambler's fallacy is the mistaken belief that past results influence future independent random events. After flipping 10 heads in a row, many people feel "tails is overdue". It isn't. With the fair setting, each new flip still has a 50% chance of heads; with a weighted setting, it still follows the selected probability. Past results do not change either probability. The fallacy arises from correctly knowing that long sequences are rare - but that rarity is assessed before the sequence begins, not after 10 heads have already occurred.

This does not mean the Law of Large Numbers is wrong: as the session grows, the observed share tends to track the average of the probabilities used so far. With a fair coin that share is 50%; under one constant weighted setting it is the selected probability. The mechanism is the accumulation of future independent flips, not the streak somehow "making up" for itself.

Teaching statistics with coin flips

  • Expected value: for n independent flips with the same heads probability p, the expected number of heads is n × p. At the fair setting p = 0.5, this becomes n/2. If rounds use different probabilities, add nᵢ × pᵢ for each round. This is a long-run average, not a guarantee for any single experiment.
  • Standard deviation: for n independent flips with the same probability p, the standard deviation of the heads count is √(n × p × (1 − p)). For 100 fair flips this is √25 = 5, so 40–60 heads is within two standard deviations and occurs about 95% of the time. With different probabilities, the variance is the sum of pⱼ × (1 − pⱼ) across coins.
  • Binomial distribution: when all n coins share probability p, the chance of exactly k heads is P(k) = C(n,k) × pᵏ × (1 − p)ⁿ⁻ᵏ, where C(n,k) is “n choose k.” The fair-coin formula uses p = 0.5; different probabilities across flips do not follow this single-p binomial formula.

Frequently asked questions

Is this a fair coin flip?

With Weighted coin turned off, each virtual flip uses a 50% heads and 50% tails probability. Results come from the browser's `crypto.getRandomValues` API; this is a fair virtual 50/50 model, while real coins may have physical biases.

Why does it sometimes streak heads or tails?

Streaks are normal in independent flips. With the fair setting, five heads in a row has probability 1/32 (about 3%). The expected heads share is 50% in that setting; with weighted flips it follows the recorded probabilities, though a short sample can vary widely.

What does the weighted coin do?

The slider sets the heads probability p from 0% to 100%. At a constant 70%, the expected heads share is 70%; if you change p during a session, the expected share is the coin-count-weighted mean of each round’s p. This mode is for probability demonstrations, not decisions.

Can I flip multiple coins at once?

Yes - set the coin count to 2–10 to flip that many simultaneously. Each coin is independently and randomly generated. The total heads and tails count for that flip is shown, and the history tracks every flip.

Browse all random generators