Lesson 17: Hypothesis Testing
🎧 Audio narration for this lesson is coming soon.
Hypothesis testing is statistics' courtroom: a claim (the null hypothesis) stands innocent until evidence convicts it beyond reasonable doubt (the significance level). It is the most conceptually demanding A-level statistics topic — and the most misinterpreted in public life. This lesson builds the full procedure for binomial and normal tests: hypotheses, test statistics, critical regions, p-values, and the correct conclusions. Master the logic here and you will read medical headlines, polls, and scientific papers with professional scepticism.
The logic — null, alternative, significance
The null hypothesis H₀ is the status quo ('the drug does nothing', 'p = 0.5'); the alternative H₁ is the claim under test ('the drug works', 'p > 0.5'). We assume H₀ true, compute how surprising the data would be, and reject H₀ only if the data is sufficiently surprising. The significance level α (usually 5%, sometimes 1%) is the threshold: reject H₀ if the data would occur with probability ≤ α under H₀. It is the reasonable-doubt standard, quantified.
One-tailed vs two-tailed: H₁: p > 0.5 (one-tailed — only large values count against H₀); H₁: p ≠ 0.5 (two-tailed — extremes either way). Choose from the question's wording BEFORE seeing data: 'test whether the coin is biased towards heads' → one-tailed; 'test whether the coin is biased' → two-tailed. Choosing after peeking at data is cheating (it doubles the false-positive rate) — examiners test this understanding explicitly.
Errors: Type I — rejecting a true H₀ (false alarm, probability α); Type II — failing to reject a false H₀ (missed detection). Lowering α reduces Type I errors but increases Type II — the eternal trade-off. In drug trials, Type I error approves a useless drug (harm!); Type II rejects a useful one (lost benefit). Context decides which error is worse — and hence whether 5% or 1% is appropriate. 'Statistically significant' means 'unlikely under H₀', not 'important' — a huge sample can make trivial effects 'significant'.
Worked example (errors in context). A smoke alarm is tested. H₀: 'there is no fire'. A Type I error (rejecting a true H₀) is the alarm sounding with no fire — annoying but cheap. A Type II error is the alarm staying silent during a real fire — catastrophic. So alarm designers accept a high Type I rate to crush the Type II rate: significance levels are chosen by consequences, not convention. In court, the asymmetry reverses: convicting the innocent (Type I) is priced far above acquitting the guilty, hence 'beyond reasonable doubt' ≈ a very small α.
Binomial tests — worked procedure
Full procedure, exam-style. Claim: a coin favours heads. Toss 20 times, observe 15 heads. Test at 5%. (1) H₀: p = 0.5, H₁: p > 0.5 (one-tailed — 'favours heads'). (2) Under H₀, X ~ B(20, 0.5). (3) Test statistic x = 15. (4) p-value = P(X ≥ 15 | H₀) = [C(20, 15) + C(20, 16) + C(20, 17) + C(20, 18) + C(20, 19) + C(20, 20)]/2²⁰. Compute: 15504 + 4845 + 1140 + 190 + 20 + 1 = 21700; 2²⁰ = 1048576; p-value ≈ 0.0207. (5) 0.0207 < 0.05 → reject H₀: there is sufficient evidence at the 5% level that the coin favours heads.
Critical region method (equivalent): find the smallest c with P(X ≥ c) ≤ 0.05: P(X ≥ 15) = 0.0207 ≤ 0.05 ✓; P(X ≥ 14) = 0.0577 > 0.05 ✗. Critical region X ≥ 15; observed 15 falls in it → reject. State the critical region explicitly — examiners award marks for it. Note the discreteness: the actual Type I error is 2.07%, not exactly 5% — binomial tests are conservative.
Two-tailed example: test if a die is biased (n = 60 rolls, 16 sixes) at 5%. H₀: p = 1/6, H₁: p ≠ 1/6. Under H₀, P(X ≥ 16) ≈ 0.0338 (via calculator CDF). Two-tailed p-value ≈ 2 × 0.0338 = 0.0677 > 0.05 → do not reject H₀. Insufficient evidence of bias. The doubling: each tail gets α/2 = 2.5%.
Normal tests — means and the CLT idea
Testing means uses the normal distribution: if X ~ N(μ, σ²) with σ known, then X̄ ~ N(μ, σ²/n) — sample means vary less than individuals (the 1/√n rule from Lesson 13, now weaponised). Example: bags of flour labelled 1.5 kg; machine sd known σ = 0.02 kg. Sample 25 bags, mean 1.494 kg. Test at 5% whether the machine underfills (H₁: μ < 1.5). Test statistic: z = (1.494 − 1.5)/(0.02/√25) = −0.006/0.004 = −1.5. p-value = Φ(−1.5) ≈ 0.0668 > 0.05 → do not reject H₀. The shortfall is not significant — it could be sampling variation.
Critical value approach: for one-tailed 5%, critical z = −1.6449; observed −1.5 > −1.6449 (not extreme enough) → do not reject. For two-tailed 5%: ±1.96; for 1%: ±2.5758 (two-tailed) or −2.3263 (one-tailed). Memorise: 1.6449 (5% one-tail), 1.96 (5% two-tail), 2.5758 (1% two-tail). These z-values are the profession's shared language — 'two sigma' and 'five sigma' (particle physics demands 5σ!) come from here.
Large samples: even if X is not normal, X̄ is approximately normal for large n (central limit theorem — stated, not proved, at A-level). So z-tests apply to large-sample means generally. But σ must be known (or n large enough to estimate it reliably) — small samples with unknown σ need the t-test (beyond A-level). State the assumption: 'assuming the sd is known/unchanged' — examiners check.
Interpreting results — what tests do and do not say
'Do not reject H₀' ≠ 'H₀ is true' — it means 'insufficient evidence against H₀'. Absence of evidence is not evidence of absence: the coin might favour heads slightly, with n = 20 too small to tell (low power). Power = P(reject H₀ | H₁ true) — bigger samples and bigger effects give more power. A non-significant result with n = 20 proves nothing; with n = 20,000 it suggests any effect is tiny. Always interpret with sample size in mind.
The p-value is P(data this extreme | H₀) — NOT P(H₀ | data). This confusion (the inverse fallacy, Lesson 15's prosecutor's fallacy in new clothes) pervades science journalism: 'p = 0.04' does not mean '96% chance the effect is real'. It means: if there were no effect, data this extreme would occur 4% of the time. Whether the effect is real also depends on prior plausibility (base rates again!).
Multiple testing: test 20 useless drugs at 5% — expect one false positive. This is p-hacking: trying analyses until one is 'significant'. Reputable science pre-registers hypotheses; A-level questions sometimes ask 'comment on the validity' when many tests were run — the answer: inflated Type I error, need Bonferroni correction (test each at α/20) or replication. The replication crisis in psychology/medicine is largely this lesson's material playing out at scale.
Full exam technique and contexts
Model answer structure: (1) State H₀, H₁ with the parameter defined (p = probability of heads); choose tails from wording. (2) State the model under H₀: X ~ B(20, 0.5). (3) Give the test statistic value. (4) Compute p-value or critical region, showing the probability statement: P(X ≥ 15) = 0.0207. (5) Compare with α and conclude in context: '0.0207 < 0.05, so reject H₀ — sufficient evidence that the coin favours heads.'
Contexts examiners use: quality control (defective rates — 'has the new process reduced defectives?'), medical trials ('is the recovery rate higher?'), the large data set ('is mean rainfall at Hurn in 2015 significantly different from 1987?'), animal behaviour, marketing claims. In each, identify: the parameter, H₀'s value, the tail direction from the claim's wording.
Assumptions to state: binomial tests need independent trials with constant p (random sampling!); normal tests need normality (or large n) and known σ. A question giving data from a convenience sample invites criticism: 'the sample may not be random, so the p-value is invalid' — linking Lessons 13 and 17. The best answers connect the whole statistics course: sampling → presentation → probability → distributions → testing, each step's assumptions checked.
Common mistakes
- Concluding 'H₀ is true'. Tests can only reject or fail to reject. 'Do not reject' plus a context sentence is the only correct conclusion format — writing 'the coin is fair' after a non-significant test is a logic error.
- Reading the p-value backwards. p = P(data at least this extreme | H₀), not P(H₀ is true). The inverse reading is the prosecutor's fallacy from Lesson 15.
- Choosing tails after seeing the data. 'Favours heads' in the wording means one tail, chosen before any tosses. Switching to one tail because the data went that way doubles the false-positive rate.
- Doubling the wrong tail (or the p-value past 1). For a two-tailed test, double the smaller tail probability. If the observation is on the 'wrong' side entirely, the p-value exceeds 0.5 — no doubling to significance is possible.
- Omitting the context conclusion. The final sentence must mention the actual claim ('...evidence that the new process has reduced the defect rate'), not just 'reject H₀'. Pure-symbol conclusions lose the communication mark.
Exam Experience
Questions in the style of the A-level statistics paper. Attempt them before reading the mark scheme.
A manufacturer claims that 30% of households own a smart meter. A researcher suspects the true proportion is higher. She surveys 20 households at random and finds that 10 own a smart meter.
1. (a) Write down hypotheses for a test of the manufacturer's claim. [2] (b) Calculate the p-value for the test. [2] (c) Using a 5% significance level, state your conclusion, with a reason. [2]
2. Bags of sugar are labelled as containing 500 g. The standard deviation of bag weights is known to be 8 g. A random sample of 36 bags has mean weight 497.2 g. Test, at the 5% level, whether the machine is underfilling bags. [5]
Mark scheme.
- 1(a) H₀: p = 0.3; H₁: p > 0.3, where p is the proportion of households owning a smart meter (B1) for both hypotheses, (B1) for one tail justified by 'suspects the proportion is higher'.
- 1(b) Under H₀, X ~ B(20, 0.3). p-value = P(X ≥ 10) (M1) for the correct tail statement. = 0.0480 (A1).
- 1(c) 0.0480 < 0.05 (M1) for the comparison. Reject H₀: there is sufficient evidence at the 5% level that the proportion owning a smart meter is higher than 30% (A1) — conclusion in context.
- 2. H₀: μ = 500; H₁: μ < 500 (underfilling is one-directional) (B1). Under H₀, X̄ ~ N(500, 8²/36), so the standard error is 8/6 = 1.333 (M1). Test statistic z = (497.2 − 500)/1.333 = −2.1 (M1). p-value = Φ(−2.1) ≈ 0.0179 (A1). 0.0179 < 0.05 → reject H₀: sufficient evidence at the 5% level that the machine is underfilling (A1).
🗺️ Interactive: Key Concepts Map
Interactive — hover or tap a concept to see its definition.
🎛️ Interactive Explorer: Quadratic Explorer — Hypothesis Testing
Drag the sliders to change the coefficients of y = ax² + bx + c and watch the parabola transform live.
Notice how a controls the width and direction, b shifts the axis of symmetry, and c moves the graph up and down.
Key Terms
- Null hypothesis (H₀)
- The status-quo claim assumed true for the test, e.g. p = 0.5.
- Alternative hypothesis (H₁)
- The claim under test; determines one- vs two-tailed.
- Significance level (α)
- The P(data|H₀) threshold for rejection — usually 5% or 1%.
- Test statistic
- The observed value (e.g. x = 15 heads) compared against H₀'s distribution.
- p-value
- P(data this extreme | H₀) — reject H₀ if p-value ≤ α.
- Critical region
- The set of test-statistic values leading to rejection.
- Type I / Type II error
- False alarm (reject true H₀, prob α) / missed detection (keep false H₀).
- Power
- P(rejecting H₀ | H₁ true) — grows with sample size and effect size.
- One-/two-tailed test
- H₁: p > value (one direction) vs H₁: p ≠ value (either direction).
- p-hacking
- Inflating false positives by running many undeclared tests.
Discussion Questions
- A darts player claims to hit the bullseye more than 20% of the time. In 30 throws she hits 10 bullseyes. Test at 5%: state hypotheses, compute the p-value exactly, find the critical region, and conclude in context.
- A machine produces rods with known sd 0.5 mm. A sample of 40 has mean 99.7 mm against a target of 100 mm. Test at the 1% level whether the mean differs from target (two-tailed). Give the z-value, p-value, and critical values.
- Explain, with the coin example (n=20, 15 heads), the difference between 'we reject H₀' and 'H₁ is proved'. Then explain why a second researcher failing to reject H₀ with n=10 does not contradict the first result.
- A pharmaceutical company tests 50 compounds at the 5% level and reports 4 'significant' results. Criticise: compute the expected number of false positives under the global null, explain p-hacking, and suggest what the company should do next.
- Using large data set reasoning: describe how you would test whether mean July maximum temperature at Heathrow differs between 1987 and 2015. State hypotheses, the test you would use, its assumptions, and how you would check them from the data extract.