Hypothesis Testing
How statisticians decide whether a result is real or just the kind of wobble chance produces anyway.
Start by assuming nothing is happening
Suppose a friend claims a coin is rigged toward heads. You flip it 10 times and get 7 heads. Is that proof? Not really — 7 heads out of 10 happens fairly often with a perfectly fair coin. But 70 heads out of 100 would make you lean forward. Hypothesis testing turns that gut reaction into a rule.
The trick is to argue from the opposite of what you suspect. You begin by assuming the boring, no-effect explanation is true — the coin is fair — and then check whether your data would be strange under that assumption. It is the statistical version of "innocent until proven guilty": the no-effect story gets the benefit of the doubt, and the data have to work to overturn it.
The logic in three moves
Once the hypotheses are set, every test follows the same three steps:
- Assume \(H_0\) is true. This gives us a specific, known distribution that our data summary should follow — the null distribution.
- Compute a test statistic. This is a single number that measures how far the data sit from what \(H_0\) expects, in units of standard error. A common form is a z-statistic.
- Ask how surprising the data are. Under \(H_0\), where does our statistic fall? Out in a far tail (surprising) or comfortably in the middle (unremarkable)?
Notice we never measure how far the data are from the alternative. Everything is judged against the single, precise world where \(H_0\) holds.
How surprising is 'surprising'? Meet the p-value
The p-value puts a number on the surprise. It is the probability, assuming \(H_0\) is true, of getting a test statistic at least as extreme as the one we actually saw. On the null distribution that probability is a tail area: the further out our statistic lands, the smaller the tail beyond it, and the more surprising the data would be under \(H_0\).
In the tool below, the bell is the null distribution — the distribution the statistic would follow if \(H_0\) were true. Slide the observed statistic and watch the shaded tail area, the p-value, shrink as the statistic moves outward. Switch between a two-sided alternative (extreme in either direction) and a one-sided one, and change the significance level to see the rejection region move.
Drawing the line: the significance level
To turn a p-value into a yes-or-no decision we pick a threshold in advance: the significance level \(\alpha\), often 0.05, sometimes 0.01. It is the tail area we agree to treat as "too surprising to chalk up to chance." If the p-value falls at or below \(\alpha\), the statistic has landed in the rejection region and we reject \(H_0\). If the p-value is above \(\alpha\), we fail to reject \(H_0\).
Choosing \(\alpha\) is choosing how often we are willing to be fooled: \(\alpha\) is the chance of rejecting a true \(H_0\) just by bad luck. A smaller \(\alpha\) demands stronger evidence before we act.
- State the hypotheses: \(H_0: \mu = 100\) ml (on target) versus \(H_a: \mu \neq 100\) ml (off target, either way).
- Assume \(H_0\) and compute the test statistic: \(z = (103.5 - 100) / 1.667 \approx 2.1\). The sample mean sits about 2.1 standard errors above the claimed value.
- Find the p-value. Two-sided, so it is both tails: \(p = 2 \times P(Z \geq 2.1) \approx 2 \times 0.0179 = 0.0357\).
- Compare to \(\alpha\): \(0.0357 \leq 0.05\), so the statistic falls in the rejection region.
Check your understanding
- A hypothesis test assumes the null hypothesis H0 (no effect) and asks how surprising the data would be if that were true.
- You compute a test statistic — the gap between the estimate and H0's value, in standard-error units — and read it against the null distribution.
- The p-value is the tail area under the null distribution: the chance, IF H0 is true, of a statistic at least as extreme as the one observed.
- A p-value is not the probability that H0 is true; it only describes how unusual the data would be under H0.
- Pick a significance level alpha in advance; reject H0 when p is at or below alpha, otherwise fail to reject.
- The verdicts are reject and fail-to-reject — never accept — because failing to reject does not prove H0, and rejecting does not prove Ha.