Coin Flip Calculator — Virtual Coin Toss Simulator

Quick Answer

A coin flip is a random event with two outcomes: heads or tails, each with 50% probability for a fair coin. Flipping a fair coin 100 times yields an expected 50 heads and 50 tails (plus or minus about 5), per the law of large numbers described in Feller's classic probability textbook.

Also searched as: coin flipper, virtual coin toss, heads or tails simulator, flip a coin online

Heads

Tails

Heads %

Longest Streak

Chi-Square p-value (fairness)

Sequence (first 500 shown):

How a Coin Flip Works

A coin flip is the canonical example of a Bernoulli trial: a single random experiment with exactly two possible outcomes, traditionally labeled heads (H) and tails (T). For a perfectly fair coin, the probability of each outcome is 0.5, and successive flips are independent, meaning one result has no influence on the next. This simple model underpins much of introductory probability theory, from the binomial distribution to Markov chains. For a deeper treatment, see Wikipedia's article on Bernoulli trials, which traces the concept to Jacob Bernoulli's 1713 work Ars Conjectandi.

This virtual simulator does not flip a physical coin. Instead, it uses JavaScript's Math.random() pseudo-random number generator (or a seeded generator if you provide a seed) to draw a number between 0 and 1 for each flip. If the draw is below your chosen probability of heads, the result is H; otherwise it is T. The results feed into live counts, a head percentage, the longest run of same-side results, and a chi-square fairness test. For repeatable experiments, supply a seed and the same sequence will be regenerated every time. Related tools include our dice roller and random number generator.

The Coin Flip Formula

The probability of getting exactly k heads in n flips of a fair coin is the binomial formula: P(X = k) = C(n, k) × 0.5^n, where C(n, k) is "n choose k." For n = 10 and k = 5, the probability of exactly five heads is C(10, 5) × 0.5^10 = 252 × 0.000977 = 0.246, or about 24.6%. The expected number of heads is n × p = n × 0.5, and the standard deviation is the square root of n × p × (1 − p), which equals about 0.5 × √n for a fair coin. The chi-square statistic for the fairness test is (observed heads − expected)² ÷ expected + (observed tails − expected)² ÷ expected, with one degree of freedom.

Key Terms You Should Know

Bernoulli trial: a single experiment with two outcomes, success (heads) with probability p and failure (tails) with probability 1 − p. Binomial distribution: the sum of n independent Bernoulli trials, which models the total number of heads in n flips. Law of large numbers: as n grows, the observed frequency of heads converges to the true probability. Streak (run): a maximal sequence of consecutive identical outcomes. Chi-square statistic: a measure of how far observed counts deviate from expected counts under a null hypothesis. Seed: an initial value that makes a pseudo-random sequence reproducible.

Coin Flip Probability — Reference Data

The table below shows exact probabilities of observing a given number of heads in 10 fair coin flips, taken from the binomial distribution B(10, 0.5). Notice that getting exactly 5 heads (the expected outcome) happens only about 24.6% of the time — most sessions fall off-center by one or two flips, which surprises many first-time users of coin flip simulators.

Heads in 10 FlipsProbabilityCumulative
00.098%0.098%
10.977%1.074%
24.395%5.469%
311.719%17.188%
420.508%37.695%
524.609%62.305%
620.508%82.813%
711.719%94.531%
84.395%98.926%

Practical Examples

Example 1 — Classroom demonstration. A statistics instructor asks students to flip a virtual coin 1,000 times. The result is 487 heads and 513 tails. The chi-square statistic is (487 − 500)² ÷ 500 + (513 − 500)² ÷ 500 = 0.676, giving a p-value of about 0.41 — well above 0.05, so there is no evidence the generator is unfair. Example 2 — Streak intuition. In 500 flips, the expected longest streak is roughly log base 2 of 500, about 9. Students are usually shocked to see a run of 8 or 9 heads in a row — it feels "rigged" but is exactly what random data looks like. Example 3 — Biased coin. A game designer sets the heads probability to 0.7 and flips 200 times. The expected heads count is 140, with a standard deviation of about 6.5; observing 145 heads is perfectly consistent with a 70%-biased coin.

Tips and Best Practices

Use at least 100 flips to test fairness. Small samples produce huge swings: 7 heads in 10 flips is not evidence of bias. Expect streaks. A streak of 6 or 7 in 100 flips is routine, not proof the coin is rigged. Seed your runs for reproducibility. When showing a sequence to students or colleagues, set a seed so the same sequence replays on demand. Do not chase the gambler's fallacy. After ten heads in a row, the next flip is still 50/50 — past results do not influence future independent flips. Prefer simulation over intuition. Running 10,000 flips here takes milliseconds and gives a far more accurate picture of probability than guessing.

Frequently Asked Questions

Is a coin flip really 50/50?

A fair coin flip has approximately a 50/50 probability of heads or tails, but real-world coins are not perfectly fair. A 2007 Stanford study by Persi Diaconis found that a flipped coin is slightly more likely (about 51%) to land on the same side it started on, due to precession during flight. For practical purposes, a coin flip is treated as a 50/50 random event, and this virtual simulator uses a true pseudo-random generator to model that ideal.

How many times should I flip a coin to test fairness?

To reliably detect unfairness, statisticians recommend flipping at least 100 times, with 1,000 or more providing strong evidence. The standard error of the proportion shrinks as 1 divided by the square root of n, so larger samples make bias easier to spot. This calculator runs a chi-square goodness-of-fit test: if the resulting p-value is below 0.05, the observed split significantly differs from 50/50 at the 5% significance level.

What is the longest streak in a coin flip?

The longest streak of consecutive same-side results in n fair flips is expected to be roughly log base 2 of n. For 100 flips, you should expect a run of about 6 or 7 heads or tails in a row, and in 1,000 flips about 10 in a row. Streaks feel unusual to humans but are a normal feature of random sequences, a fact documented in classic probability textbooks such as Feller's 'An Introduction to Probability Theory.'

Can a coin land on its edge?

Yes, but it is extraordinarily rare. A 1993 study by physicist Daniel Murray calculated the probability of an American nickel landing on its edge at roughly 1 in 6,000 flips on a hard surface. For practical coin-flip decisions, edge landings are ignored, and virtually all probability models, including this calculator, treat the outcome as strictly binary: heads or tails.

How does a biased coin calculator work?

A biased coin calculator lets you set the probability of heads to any value between 0 and 1 instead of the default 0.5. Each simulated flip draws a random number; if it falls below the chosen probability, the result is heads. This is useful for modeling weighted coins, teaching probability, or simulating Bernoulli trials in statistics courses, where the coin represents any two-outcome random event.

What is a chi-square fairness test?

A chi-square goodness-of-fit test compares observed counts to expected counts under a null hypothesis. For a coin, the expected counts are n divided by 2 heads and n divided by 2 tails. The test statistic sums the squared difference divided by the expected value for each category. With 1 degree of freedom, a chi-square statistic above 3.84 gives a p-value below 0.05, suggesting the coin is unfair.

Related Calculators