Lesson 12 / 13 · 14 min read
Hypothesis Testing
Null vs alternative, test statistics, p-values, and the two ways to be wrong.
The logic
A hypothesis test asks: is the effect I'm seeing real, or could plain chance explain it? We start by assuming nothing is going on, then check whether the data is too surprising for that assumption to survive.
Null and alternative hypotheses
- Null hypothesis H0: no effect, no difference — the status quo. For example μ=100.
- Alternative hypothesis Ha: the claim we're testing. For example μ=100 (two-sided) or μ>100 (one-sided).
We never "prove" H0. We either reject it or fail to reject it.
The test statistic
For a mean, the test statistic counts how many standard errors xˉ sits from the null value μ0:
z=σ/nxˉ−μ0
The p-value
The p-value is the probability — assuming H0 is true — of getting a result at least as extreme as the one observed.
- Small p-value → the data would be very unlikely under H0 → evidence against H0.
- Large p-value → the data is consistent with H0.
Significance level
Choose a threshold α (often 0.05) in advance:
- If p≤α: reject H0 — the result is "statistically significant."
- If p>α: fail to reject H0.
Worked example
A factory claims its bottles average μ0=500 ml. A sample of n=64 bottles gives xˉ=497 with σ=8. Test Ha:μ=500 at α=0.05.
z=8/64497−500=1−3=−3
For a two-sided test, the p-value is P(∣Z∣>3)≈0.0027. Since 0.0027<0.05, we reject H0 — the fill amount differs significantly from 500 ml.
Two kinds of error
| H0 is true | H0 is false | |
|---|---|---|
| Reject H0 | Type I error | correct |
| Fail to reject | correct | Type II error |
- Type I error: rejecting a true null — a false positive. Its probability is α.
- Type II error: failing to detect a real effect — a false negative. Its probability is β.
- Power =1−β: the chance of catching a real effect. A larger sample raises power.
Significant is not the same as important
With a big enough sample, even a tiny, meaningless difference can come out "statistically significant." Always look at the size of the effect, not just the p-value.
Key takeaways
- H0 = no effect; Ha = the claim. You reject or fail to reject — never prove H0.
- z=(xˉ−μ0)/(σ/n); the p-value measures how surprising the data is under H0.
- Reject when p≤α (commonly 0.05).
- Type I = false positive (rate α); Type II = false negative (rate β); power =1−β.
- Statistical significance = practical importance.