The idea: is this coin fair?

A friend's coin lands heads 62 times in 100 flips. Is the coin biased, or was that just luck? A hypothesis test answers with a fixed recipe: assume the boring explanation, work out how surprising the data would be under it, and give it up only if the data would be very surprising.

Five boxes left to right joined by arrows: H0, the coin is fair, p = 0.5; flip 100 times; statistic X = 62 heads; p-value = P(as extreme as 62 given H0) = 0.021; compare with alpha = 0.05: 0.021 is at most 0.05, so reject H0.
Every test follows the same five steps: hypothesis, data, one number, a tail area, a fixed cut-off.

The canvas shows the recipe on one coin. The top chart is what H₀ predicts, the bottom chart is the coin as it really is (you choose it; the test never sees it), and the table on the right counts the four ways a decision can turn out.

Null and alternative hypotheses

The null hypothesis H₀ is the claim of "no effect" that the test tries to knock down: here p = 0.5, the coin is fair. The alternative H₁ is what we accept if H₀ falls: p ≠ 0.5. This H₁ is two-sided: too many heads and too few tails both count as evidence. A test never proves H₀; it only finds the data consistent or inconsistent with it.

The test statistic and its null distribution

The 100 flips are squeezed into one number, the test statistic: X = the number of heads. If H₀ is true, X follows the binomial distribution Binomial(100, 0.5): mean 50, standard deviation 5. That is the top chart, the null distribution. Each bar is P(X = k) = C(100, k) / 2100 (see Pascal's triangle for where C(n, k) comes from).

The p-value is a tail area

The p-value is the probability, if H₀ is true, of a result at least as extreme as the one observed. For 62 heads, "at least as extreme" means at least 12 away from 50, on either side:

p = P(X ≥ 62 or X ≤ 38 | p = 0.5) = 0.0105 + 0.0105 = 0.0210

On the canvas this is the orange area: the bars in both tails beyond the observed x (Demo: 62 heads → p = 0.021, reject H₀). 60 heads looks almost as odd, but its tails hold p = 0.0569 (Demo: 60 heads → p = 0.057, keep H₀).

Bar chart of Binomial(100, 0.5) from 30 to 70 heads centred on 50. The bars at 38 and below and at 62 and above are orange, each tail labelled 0.0105; a line marks x = 62. Caption text: p-value = 0.0105 + 0.0105 = 0.021.
The p-value of 62 heads: both orange tails of the null distribution, 2 × 0.0105 = 0.021.
heads xdistance from 50two-sided p-valueat α = 0.05
5880.1332keep H₀
60100.0569keep H₀
61110.0352reject H₀
62120.0210reject H₀
65150.0035reject H₀

α and the rejection region

The significance level α is chosen before looking at the data: how small a p-value must be to reject H₀. Rejecting when p ≤ α is the same as rejecting when X lands in the rejection region: the most extreme outcomes whose total probability under H₀ is at most α (the red bars). X can only be a whole number, so the region cannot hit α exactly; its real size is a bit less (Demo: α sets the rejection region).

αreject H₀ whenreal sizepower if p = 0.6power if p = 0.65
0.10X ≤ 41 or X ≥ 590.088662.3%91.2%
0.05X ≤ 39 or X ≥ 610.035246.2%82.8%
0.01X ≤ 36 or X ≥ 640.006623.9%62.7%

Type I and type II errors

The test sees only X; the truth about the coin is hidden. So there are four outcomes:

keep H₀reject H₀
H₀ true (fair coin)correct, 1 − αtype I error (false alarm), α
H₀ false (biased coin)type II error (missed effect), βcorrect, power = 1 − β

With a fair coin, every rejection is a false alarm, and α caps how often that happens. Repeating the test 100 times on a fair coin rejects 3 times, close to the real size 3.5% (Demo: type I errors with a fair coin). Medical screening has the same table: a false positive is a type I error, a missed disease a type II error (see Bayes' theorem for why a "significant" positive can still be more likely false than true).

Power

The power of a test is the chance it rejects H₀ when H₀ is false. It is not one number: it depends on how far the truth is from H₀. On the bottom chart, power is the green area of the real coin's distribution inside the red region, and β is the rest. A 60% coin is caught only 46% of the time with 100 flips at α = 0.05: 48 of 100 repeated tests in Demo: power against a 60% coin; a 65% coin, 83% of the time.

Two bar charts sharing a heads axis from 30 to 80, with dashed red lines at 39.5 and 60.5. Top: Binomial(100, 0.5); the bars outside the lines are red, area alpha = 0.035, type I. Bottom: Binomial(100, 0.6) centred on 60; bars at 61 and above are green, power 46.2%; bars from 40 to 60 are red, beta 53.8%, type II.
The cut-offs come from the H₀ chart; the real coin decides how much of its mass falls beyond them.

Three things raise power: a bigger true effect, more data (with n = 400 flips a 60% coin is caught almost always, because the spread of X/n shrinks like 1/√n, see the central limit theorem), and a larger α. The last one costs more false alarms: shrinking α from 0.05 to 0.01 cuts the power against a 60% coin from 46% to 24% (Demo: smaller α, less power). Studies choose n in advance so that power is at least 80% for the smallest effect worth finding.

What a p-value is not

  • It is not the probability that H₀ is true. It is computed assuming H₀ is true.
  • p > α does not show the coin is fair; the test may simply lack power (60 heads keeps H₀ although a 60% coin produces it often).
  • A tiny p-value does not mean a big effect: with a million flips, 50.2% heads is "significant".
  • Running many tests and reporting the one with p ≤ 0.05 makes false alarms almost certain (p-hacking).

For a normal statistic the same logic uses z-scores and the bell curve instead of binomial bars, see normal distribution, z-scores and confidence intervals; a 95% confidence interval excludes a value exactly when the two-sided test of that value rejects at α = 0.05.

What the page leaves out

  • One-sided tests (H₁: p > 0.5), which put all of α in one tail.
  • The normal approximation z = (X − 50)/5 and the continuity correction; the page uses exact binomial probabilities.
  • Other tests: t-tests, chi-square, permutation tests, tests comparing two groups (A/B tests).
  • Multiple-testing corrections (Bonferroni, false discovery rate) and sequential tests that peek as data arrives.
  • Bayesian alternatives: Bayes factors and posterior probabilities for p itself.