Hypothesis Testing
A hospital tries a new drug on a hundred patients. Sixty of them get better. Wonderful — but
wait. On this illness, roughly half of all patients recover on their own anyway, drug or
no drug. So the real question is not "did patients improve?" It is:
did the drug actually do anything, or did this batch of patients just get lucky?
That single question — real effect, or random luck? — is asked millions of times a year,
about medicines, teaching methods, web-page tweaks, crop yields, and coin tosses.
Hypothesis testing is the formal machinery statistics built to answer it. It is,
quite deliberately, a courtroom: it starts by assuming nothing is going
on, and asks whether the evidence is strong enough to overturn that assumption
beyond reasonable doubt.
A hypothesis test is a courtroom for a claim. We put a default position on
trial and ask whether the data give us enough reason to overturn it. The two competing claims
are:
-
the null hypothesis H_0 — "no effect", the
status quo, the thing we assume true until shown otherwise;
-
the alternative hypothesis H_1 — the claim of a
real effect, what we suspect instead.
For a population mean, a typical pair is
H_0: \mu = \mu_0 \qquad\text{versus}\qquad H_1: \mu \ne \mu_0.
Like a defendant, H_0 is presumed innocent. The burden of proof is
on the data.
The logic: assume, then be surprised
The move at the heart of every test is this. Assume
H_0 is true. Under that assumption, the
sampling distribution of the mean
is known — it is a bell centred on \mu_0. Now compute a
test statistic from the data and ask: how surprising is a value this
extreme, if H_0 really holds?
- A value near the centre is unremarkable — exactly what H_0 predicts.
- A value far out in a tail would be a rare fluke under H_0.
If the observed statistic lands far enough into the tail, we judge the data
too surprising to square with H_0, and we
reject it in favour of H_1. Exactly how
surprising is captured by a single number, the
p-value, which
you will meet next.
Setting up the two hypotheses
Half the skill of testing is just writing down H_0 and
H_1 correctly. The rule of thumb never changes:
H_0 is always the boring "no difference" claim, and
H_1 is the interesting thing you actually hope to show. Work through
three:
-
Is this coin fair? The "nothing going on" claim is that it lands heads half
the time. So
H_0: p = 0.5 versus H_1: p \ne 0.5. You
flip it 100 times and get 63 heads. Is 63 a surprising haul if the coin really is fair? That is
the whole test.
-
Does a new teaching method beat the old one? The status quo is that it makes
no difference to scores: H_0: \mu_{\text{new}} = \mu_{\text{old}}.
The hope is H_1: \mu_{\text{new}} > \mu_{\text{old}}. Notice the
direction — here we only care if the new method is better, a
one-sided alternative.
-
Did the drug work? H_0: the recovery rate is the
same as the natural rate, 0.5.
H_1: it is higher. Sixty of a hundred recovering is a bit above
0.5 — but is it far enough above to rule out plain luck?
In every case the recipe is identical: assume the boring claim, then measure how startled we
should be by the data we actually got.
How surprising is the data?
Below is the null sampling distribution — the bell we would see if
H_0 were true, drawn in z-units (standard
deviations from \mu_0). Slide the observed statistic
and watch where it falls. Out near the centre it is business as usual; pushed far into a tail
it becomes a value H_0 rarely produces — the kind of surprise that
argues against H_0.
Innocent until proven guilty
The courtroom analogy is not a loose metaphor — it is exact, and worth taking apart carefully:
-
H_0 is the presumption of innocence. The court
starts by assuming the defendant did nothing wrong, just as the test starts by assuming there is
no effect.
-
The data are the evidence. A jury does not convict on a hunch; it needs
evidence strong enough to be surprising if the defendant were truly innocent.
-
"Reject H_0" is a guilty verdict. The evidence was
too improbable under innocence, so we overturn the presumption.
-
"Fail to reject H_0" is "not guilty" — not "innocent".
It says the evidence fell short of the bar, nothing more.
And, just like a real trial, the burden of proof sits entirely on one side. We do not ask the
defendant to prove innocence; we ask the prosecution to prove guilt. In a test we never ask the
data to prove H_0; we only ask whether they can overturn it.
We never prove H₀
A test has only two verdicts: reject H_0, or
fail to reject H_0. The second is not a
proof of H_0 — exactly as "not guilty" is not the same as "innocent".
It means only that the data were not surprising enough to convict. Absence of evidence against
H_0 is not evidence that H_0 is true.
- H_0 (null) is the "no effect" default; H_1 (alternative) is the claim of an effect.
- Assume H_0, then measure how surprising the data are under it.
- Surprising data (a statistic far in the tail) ⇒ reject H_0.
- "Fail to reject" ≠ "prove H_0" — we never establish the null, only fail to overturn it.
This is the mistake that trips up nearly everyone, including trained scientists. A test that comes
back "not significant" is not a stamp that says "H_0
is true". Absence of evidence is not evidence of absence.
A quiet result has (at least) two very different explanations:
- There really is no effect — the drug genuinely does nothing; or
-
the effect is real but your sample was too small to see it. A tiny study is
like a blurry photograph: a real object can be present and still not show up. Test the same drug
on 20 patients and you may find nothing; test it on 20,000 and the very same effect leaps out.
Because a "no effect" verdict can be a genuine null or a missed real effect, we are
always at risk of one of two mistakes — convicting an innocent null, or acquitting a guilty one.
Those two failure modes have names and probabilities of their own, which you will meet in
Type I and Type II errors.
A criminal trial is not fair to both sides on purpose. It is rigged to protect the innocent: the
system would rather let a guilty person walk free than jail an innocent one. Hypothesis testing is
built with the same deliberate tilt. It would rather miss a real effect than
announce a fake one — because a false discovery, published and believed, does more damage
than a quiet miss.
That is why science demands a small p-value before it will accept a new claim: the bar to
"convict" H_0 is set high on purpose, to guard against being fooled by
random noise. Data are noisy, humans love to see patterns, and a lot of apparent "effects" are
just the ordinary jitter of chance dressed up as a discovery.
The flip side of this caution is the modern replication crisis: whole shelves of
published findings in psychology and medicine turned out not to reproduce when other labs tried
them. A big part of the blame is the misuse of this exact framework — running dozens of
tests and reporting only the one that "worked", or treating a barely-significant fluke as settled
truth. The machinery is sound; it just has to be used honestly.
See it explained