Overview
Curated: · Written: · Reviewed:
Hypothesis Testing
In one line
Hypothesis testing checks whether the data is compatible with a stated null of no effect. Reach for it before shipping a change or claiming two options differ. The output is evidence against the null under a stated model, not the probability that the change works.
Key definitions
- p-value: probability of data at least this extreme if the null is true. It is not P(null | data).
- Type I error: rejecting a true null. Its rate is bounded by alpha.
- Type II error: failing to reject a false null. Its rate is 1 minus power.
- Power: probability of detecting a stated effect at alpha, fixed before the test runs.
- MDE: the smallest effect the design detects reliably at the chosen alpha and power.
- TOST: two one-sided tests against a margin set in advance. It is the only valid route to 'no meaningful difference'.
Formulas and complexity
Twenty independent tests at alpha 0.05:
Bonferroni rejects p_i when p_i ≤ alpha/m. Benjamini-Hochberg rejects up to the largest k with p_(k) ≤ (k/m)q.
How it works
Fix alpha, power, MDE and n before data arrives. Compute the statistic under the null and compare p with alpha. Then read the confidence interval against the practical threshold, not against zero alone. Randomise at the unit you analyse, or cluster the errors.
When to use and when not to
| Situation | Use | Avoid |
|---|---|---|
| Two independent means, unequal variance | Welch t-test | Pooled Student t-test |
| Two proportions, large n | Two-proportion z-test | Z-test on tiny counts |
| Small counts, pilot | Fisher exact test | Z-test or chi-squared with small expected counts |
| Skewed data, small n | Bootstrap for the mean, or Mann-Whitney stated as ordering | t-test on heavy skew |
| Claim of no meaningful difference | TOST against a pre-set margin | Non-significant difference test |
| Many exploratory metrics | Benjamini-Hochberg | Bonferroni over hundreds of metrics |
| Few confirmatory metrics | Bonferroni or fixed horizon | Per-metric peeking |
| Continuous monitoring | Group sequential boundaries or always-valid inference | Repeated fixed-sample tests |
Traps interviewers probe
- Reading p = 0.03 as a 3% chance the null is true. Fix: say it is the chance of data this extreme if there were no difference, then report the effect and its interval.
- 'Not significant, so the two are equivalent.' Fix: run TOST with a margin set beforehand, and require the 90% CI to sit inside it.
- Post-hoc power computed from the observed effect. Fix: compute the MDE or power for the smallest effect worth acting on, before launch.
- Analysing page views when randomising users. Fix: aggregate to the user or use clustered errors, since raw rows make intervals too narrow.
- Stopping at the first significant peek, or switching to one-sided after seeing the sign. Fix: fix n or use group sequential boundaries, and fix sidedness in the plan.
Interview tips
Open with: 'The p-value is the chance of data this extreme if there were no difference. I lead with the effect and its interval against the threshold we set before the test.'
Follow-ups to expect:
- Post-hoc power: it is a function of the p-value you already have, so it adds no information.
- Choosing alpha: set it from the cost of each error, written down before launch. A false positive that ships a regression and a false negative that leaves a real win unshipped have different costs, so 0.05 should not be the default by habit.
- Sample ratio mismatch: 12,340 and 11,660 users against 12,000 expected per arm gives a chi-squared statistic of 9.63 + 9.63 = 19.3 on one degree of freedom, p ≈ 1 × 10^-5. Treat the result as invalid until the assignment logic is checked.
- Welch versus pooled: default to Welch, and never choose between them after looking at the variances.
30-second outline: the claim, the design (alpha, power, MDE, n), the effect with its CI, the decision against the practical threshold, the checks (sample ratio, deviations from plan), then what remains open.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.