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:

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?

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:

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:

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.

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:

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