Understanding the coin flipper — concept and principle
This tool flips a fair virtual coin as many times as you like and shows the sequence, the counts of heads and tails, the longest run and how likely that exact number of heads was. Use it to settle a choice, run a classroom probability experiment or see what real randomness looks like.
How it is calculated
- Each flip is an independent 50/50 draw from your browser's cryptographic random generator (crypto.getRandomValues), using an unbiased mapping.
- Heads share = heads ÷ flips × 100.
- Expected heads = n ÷ 2; standard deviation = √n ÷ 2.
- Chance of exactly k heads = C(n, k) ÷ 2ⁿ (binomial distribution).
- The result stays until you change an input; change the flip number to flip again.
The principle
A fair coin has no memory: each flip is 50/50 whatever came before. Over many flips the share of heads settles near 50 % (the law of large numbers), but the count can still wander: with n flips the number of heads typically varies by about √n ÷ 2 around n ÷ 2. Runs of the same side are far more common than people expect; a sequence that alternates too neatly is a sign of human invention rather than chance.
Worked example
Default inputs: 10 flips, flip number 1. The flips are random, so the page may show a different result each time; when this page was checked it gave:
- Sequence T H H T T H T H H H: 6 heads and 4 tails; last flip Heads.
- Heads share = 6 ÷ 10 = 60 %; expected heads for a fair coin = 5.
- Longest run of the same side = 3 (the last three heads).
- Chance of exactly 6 heads = C(10, 6) ÷ 2¹⁰ = 210 ÷ 1,024 = 0.2051.
How to read the result
Results like 6–4 or 7–3 in 10 flips are completely normal; even 8–2 happens about 4–5 % of the time in one direction. Only with hundreds of flips does the share reliably sit close to 50 %. A long run does not make the other side "due".
Common mistakes
- Believing tails is due after several heads (the gambler's fallacy).
- Expecting exactly half heads in a small number of flips.
- Thinking a sequence like H H H H is less likely than H T T H; every exact sequence of 4 has probability 1/16.
- Using a virtual coin for decisions with legal or financial consequences.
Frequently asked questions
Is an online coin flip fair?
This one uses the browser's cryptographic random generator with an unbiased mapping, so each flip is 50/50.
What is the chance of 10 heads in a row?
1 in 1,024, about 0.1 %.
How long is the longest run in 100 flips?
Usually around 6 or 7.
Sources: W3C Web Cryptography API, crypto.getRandomValues · Binomial distribution, standard probability theory