Coin Flip

Flip a fair coin, or a whole handful, and watch the session statistics build: heads, tails, percentages, and your longest streak, with the probability math explained below.

Session tally

0heads
0tails
—heads share
—longest streak

Click “Flip”. Each coin is an independent fair bit.

How this calculator works

Each coin is one random bit from the browser's cryptographic generator, an even 50/50 with no starting-side bias (a real coin is very slightly biased, as the FAQ explains). Set the count to flip several coins at once. The session tally adds up across clicks: total heads and tails, the running heads percentage, and the longest streak on either side.

The heads percentage swings widely over the first dozen flips and then settles toward 50% as the session grows, which is the law of large numbers at work. The streak counter shows how often long runs turn up with a fair coin.

The formula

P(heads) = 1/2 per flip, flips independent

P(exactly k heads in n flips) = C(n, k) / 2ⁿ
P(streak of s starting at a given flip) = 1 / 2ˢ

The binomial distribution governs multi-coin flips. Any introductory probability text covers it (e.g., Blitzstein & Hwang, Introduction to Probability, the Harvard course text). The aside about physical coins being ~51% biased toward their starting side is Diaconis, Holmes & Montgomery, "Dynamical Bias in the Coin Toss," SIAM Review 49(2), 2007.

Worked example

Flip 10 coins at once and ask: how likely is exactly half heads?

  1. Ways to choose which 5 of 10 coins are heads: C(10,5) = 252
  2. Total equally likely outcomes: 2¹⁰ = 1,024
  3. P(exactly 5 heads) = 252 ÷ 1,024 = 24.6%
  4. Meanwhile P(4, 5, or 6 heads) = (210 + 252 + 210) ÷ 1,024 = 65.6%

"Roughly half" is common. "Exactly half" happens only a quarter of the time. Set the coin count to 10 and flip a dozen times. Your tally of exactly-5 results should land near 3 of 12.

Assumptions & tips

  • Set the terms before the flip. Agree on who is heads, how many flips, and that the result stands before anyone flips.
  • Expect streaks. In 25 flips, the chance of a run of five is close to even. If a streak would ruin your game or classroom demo, decide in advance how you'll treat it.
  • Use multi-coin mode for binomial demos. Flip ten coins per click and tally the heads counts, and a bell shape appears within a few minutes.
  • Don't even things out by hand. Re-flipping until the tally looks balanced adds a bias the coin doesn't have.
  • More than two options? The spinner wheel uses the same random generator for any number of options.

Frequently asked questions

Is a virtual coin flip fairer than a real one?

Slightly, yes. Stanford researchers (Diaconis, Holmes, and Montgomery, 2007) showed that a real caught coin has about a 51 percent bias toward landing the same way up it started, because of the physics of precession. This page's flip is a single cryptographically random bit: exactly 50/50, with no starting side to favor. For settling arguments, both are fine. For teaching probability, the digital coin is the closer match to the textbook model.

I got five heads in a row. Is the coin broken?

No. Five heads in a row has chance 1/32 from any given starting flip, and across a session of 25 flips there is roughly a 50 percent chance of seeing a streak of five somewhere. Long runs are normal in fair sequences, and people who try to fake random data tend to leave them out.

What are the odds of exactly half heads?

Lower than intuition says. In 10 flips, exactly 5 heads happens 24.6 percent of the time. In 100 flips, exactly 50 heads is only 8 percent. "About half" is overwhelmingly likely, but "exactly half" gets rarer as flips grow, because the binomial distribution spreads over more outcomes.

Sources

  1. Web Cryptography API. World Wide Web Consortium (W3C) Recommendation, 26 January 2017. §10.2.1, the getRandomValues method. w3.orgDefines crypto.getRandomValues, the source of the single cryptographically random bit behind each flip and the basis for calling this coin exactly 50/50.
  2. Dynamical Bias in the Coin Toss. Persi Diaconis, Susan Holmes and Richard Montgomery, SIAM Review, volume 49, number 2, pages 211–235, 2007. DOI 10.1137/S0036144504446436. stat.berkeley.eduThe high-speed-photography measurement behind the FAQ's claim that a real caught coin lands the way it started about 51% of the time, and the precession argument that explains it. Linked to a freely readable university copy; the SIAM version is paywalled.
  3. Introduction to Probability. Charles M. Grinstead and J. Laurie Snell, 2nd edition, American Mathematical Society, 2003; freely redistributable edition dated 2006. math.dartmouth.eduChapter 3 for the combinations and binomial probabilities behind the worked example (252 of 1,024 ways to get exactly 5 heads in 10), and Chapter 8 for the law of large numbers that governs the drifting heads share in the session tally.
  4. Introduction to Probability. Joseph K. Blitzstein and Jessica Hwang, 2nd edition, Chapman and Hall/CRC, 2019. ISBN 978-1-138-36991-7. The introductory text this page's formula section names for the binomial distribution governing multi-coin flips and the independence of successive flips. Cited bibliographically: no stable free full text to link.
  • Random Team Picker

    Split any list of names into fair random teams: unbiased shuffle, by team count or team size.

  • Spinner Wheel

    Add your options, spin the wheel, get a fair pick. The result comes from an unbiased RNG, not the animation.

  • Blackjack Odds Calculator

    Exact dealer bust rates by upcard and the true EV of standing, hitting, or doubling any hand.

  • Poker Odds Calculator

    Outs to exact turn and river odds, the rule of 2 & 4 checked, and pot-odds break-evens for Hold’em.