Uttir
By Uttir 7 min read

The Math Behind a Fair Coin Flip (and Why Your Brain Lies About It)

A coin flip is the simplest random experiment. The math is 50/50, the physics is messy, and your brain is the worst part. Here is what "fair" actually means, why a flipped coin is not exactly 50/50, why 100 flips rarely show exactly 50/50, and how to verify a tool is using real randomness.

A fair coin flip is 50/50 in theory and 50.8/49.2 in practice (the flipped side lands slightly more often because of physics, not bias). Over 100 flips, the observed split is almost always between 40/60 and 60/40; over 1,000 flips, between 47/53 and 53/47. The expected split is 50/50, but the observed split converges to that only over many trials. A tool that uses the browser's built-in secure random number generator is genuinely fair. The <a href="/coin-flip">Coin Flip</a> uses that source and runs entirely in the browser — no server, no upload.

A coin flip looks like the simplest random experiment in the world. Two outcomes, equal chance, you flip it in the air and look at the result. The math is elementary. The physics is not. Your brain is the worst part of all.

What "fair" means

A fair coin is a coin where each side has an equal chance of landing face-up. For a perfectly symmetric coin flipped in a perfectly random way, the probability of heads is 0.5 and the probability of tails is 0.5. This is the textbook answer.

In practice, no coin is perfectly symmetric (they have different designs on each side, which can shift the center of mass) and no flip is perfectly random (the flipper's hand motion introduces a small bias). The 0.5/0.5 textbook answer is the limit, not the reality. For most purposes, "fair" means "the result is unpredictable before the flip" — which a real coin flip is, even if it is not exactly 50/50.

Why a flipped coin is not exactly 50/50

There is a famous 2007 paper by Persi Diaconis, Susan Holmes, and Richard Montgomery at Stanford that analyzed the physics of a coin flip in detail. The conclusion: a coin flipped by a human is slightly biased toward the side that was face-up at the start of the flip. The bias is about 51/49, not 50/50.

The reason is the physics of the flip. When you flip a coin, the coin rotates around an axis that is not perfectly perpendicular to the ground. The slight tilt means the coin spends more time with the initial face-up side facing up. By the time the coin lands, the initial face-up side has a 51% chance of being face-up.

For most uses, a 1% bias does not matter. If you flip 100 coins, the expected split is 51/49, not 50/50, but the difference is within the noise of small samples. If you flip 10,000 coins, the bias becomes detectable, and the split will be noticeably off from 50/50. The bias is real, but it is small enough that the coin flip is still a useful random source for low-stakes decisions.

Why 100 flips rarely show 50/50

Even with a perfectly fair coin, the observed split after 100 flips is almost never exactly 50/50. The most likely outcome is 50 heads and 50 tails, but the probability of that exact outcome is only about 8%. The probability of being within 5 of 50/50 (i.e., 45-55 split) is about 73%. The probability of being within 10 of 50/50 is about 97%.

In other words, even with a perfect coin, you are 27% likely to see a split outside 45-55 after 100 flips. If you flip 100 coins and get 47 heads and 53 tails, the coin is not necessarily biased — the result is within the range of normal variation.

The pattern of small samples not matching the expected probability is called the law of small numbers. It is one of the most common sources of confusion in probability. The coin is not biased. Your intuition is biased.

What "convergence to the mean" actually means

Over many trials, the observed frequency converges to the true probability. For a fair coin, the true probability is 0.5. After 10 flips, the observed frequency might be anywhere from 0.2 to 0.8. After 100 flips, it is almost always between 0.4 and 0.6. After 1,000 flips, between 0.47 and 0.53. After 10,000 flips, between 0.49 and 0.51. The observed frequency tightens around the true probability as the number of trials increases.

This is the law of large numbers, and it is one of the most important results in probability. But it does not mean the next flip is more likely to be tails because the last ten were heads. Each flip is independent. The "convergence" is about the average over many trials, not about the next single trial.

The gambler's fallacy, in practice

The most common mistake is the gambler's fallacy: thinking that a streak of heads makes tails "due" on the next flip. This is wrong. Each flip is independent. The coin does not remember the previous flips. After 10 heads in a row, the probability of heads on the next flip is still 0.5 (assuming a fair coin). The streak does not change the probability.

But the gambler's fallacy is not random either. The pattern of the streak (10 heads in a row) is itself unlikely. If you see 10 heads in a row, the coin is either (a) fair and you got a 1-in-1024 outcome, or (b) biased toward heads. You can update your belief in (b) after seeing 10 heads. The fallacy is not in updating the belief — it is in thinking the next flip is "due" to be tails. The next flip is still independent.

For a coin flip in real life, the prior probability of a fair coin is so high (most coins are fair) that 10 heads in a row is not strong evidence of bias. You would need closer to 1,000 heads in a row to start suspecting the coin. With 10, the most likely explanation is "I got a 1-in-1024 outcome on a fair coin."

How to verify a tool is using real randomness

For a tool to give a fair coin flip, it needs a source of randomness that is not predictable. There are a few common sources, in order of quality:

  1. Hardware random number generators (thermal noise, photoelectric effect, quantum vacuum fluctuations) — the gold standard, used in research and cryptography.
  2. Operating system entropy (Windows CNG, Linux /dev/urandom, macOS SecRandomCopyBytes) — uses hardware RNG under the hood, very high quality.
  3. Browser built-in secure random (crypto.getRandomValues) — uses OS entropy, suitable for any user-facing application.
  4. Math.random() in most languages — a software pseudo-random number generator. Not cryptographically secure, but unpredictable enough for games and simulations.
  5. Date.now() or other time-based entropy — predictable. Not random at all.

For a coin flip tool, the source needs to be unpredictable. Browser built-in secure random is the right answer: it is unpredictable, it runs in the browser, and it does not require a server. A tool that uses Math.random() is also fine for non-security uses, but it is technically less random than crypto.getRandomValues.

The way to tell which source a tool uses: look at the code. The source should be visible. If you cannot see it, assume the worst. A tool that claims to use "true randomness" but uses Math.random() is misleading you. A tool that uses crypto.getRandomValues and says so is being honest.

What "fairness" means for a tool

A tool's coin flip is "fair" if:

  • The probability of heads is 0.5 (within the noise of small samples).
  • The result is not predictable before the flip.
  • The result is not influenced by anything the user did or did not do (no client-side manipulation, no server-side bias).

The first condition is about the probability. The second is about the source. The third is about the implementation. All three have to be true for the tool to be fair.

For a tool that runs entirely in the browser, the third condition is satisfied by default: there is no server, so the server cannot bias the result. The first condition is satisfied by using a fair source (like crypto.getRandomValues). The second condition is satisfied by using a non-predictable source.

How to test if a tool is fair

You cannot prove a tool is fair by running it a few times — small samples are noisy. To get a meaningful test, you need to run the tool thousands of times and look at the distribution. A fair tool will show a split close to 50/50 with the expected noise around it.

For a quick check, run the tool 100 times. If the split is between 40/60 and 60/40, the tool is plausibly fair. If the split is consistently 30/70 or worse, the tool is biased. This is not a definitive test, but it is a quick sanity check.

For a more rigorous test, run the tool 10,000 times. The expected split is 50/50 with a standard deviation of sqrt(10,000 * 0.5 * 0.5) = 50. So the observed split should be 5000 ± 100 (within 2 standard deviations) for a fair tool 95% of the time. If the tool is consistently outside this range, the tool is biased.

The Coin Flip tracks the session's heads/tails count. Run it 100 times in a row, look at the count, and you can do the quick sanity check on the distribution. If the count is between 40 and 60 heads, the tool is plausibly fair. If it is outside that range consistently, the tool has a problem.

The summary

A coin flip is the simplest random experiment, and the math is elementary. A real coin flip has a small bias (about 51/49) that is detectable over thousands of trials. Small samples are noisy and the noise is what most people mistake for bias. The right source of randomness for a tool is the browser's built-in secure random, which uses the operating system's hardware entropy. The way to verify a tool is fair is to run it many times and check the distribution.

Used correctly, a coin flip is a useful tool. Used incorrectly — for high-stakes decisions, for breaking the law of small numbers, for "due" flips — it is a way to fool yourself. The math does not lie. Your brain does.

#randomness#probability#math#coin-flip#statistics#cryptography

New tools and guides, once a week

One short email when something new ships. No tracking, no images, unsubscribe with one click.