1.3.20 · D3Probability & Statistics

Worked examples — Hypothesis testing and p-values

2,966 words13 min readBack to topic

This page is a worked-example gauntlet. The parent note showed you the machinery once. Here we run it through every shape a problem can take: one tail, two tails, the boundary where the p-value exactly equals , a degenerate "zero difference" input, a limiting "huge sample" case, a real-world word problem, and an exam-style trap. If you meet a case here, you have already seen it.

Before we start, one promise: every symbol used below is either defined in the parent or re-earned here. When a number pops out, it is checked in the verify block.


The scenario matrix

Think of a hypothesis test as a machine with knobs. The knobs are: which tail(s) we look at, the sign of the observed effect, and how extreme the input is. The table below lists every knob-setting we must cover so nothing surprises you later.

Cell Case class What makes it tricky Covered by
A Two-tailed, positive effect must double the tail; direction doesn't matter Ex 1
B Two-tailed, negative effect is negative — do we flip a sign? Ex 2
C One-tailed, right side only "bigger" counts; don't double Ex 3
D One-tailed, wrong direction effect goes the opposite way you hoped Ex 4
E Boundary case: p-value reject or not? the " vs " edge Ex 5
F Zero / degenerate input observed = null exactly, Ex 6
G Limiting case: huge tiny effect becomes "significant" Ex 7
H Real-world word problem you must build yourself Ex 8
I Exam twist: given a target p-value, find the cutoff run the machine backwards Ex 9

Three definitions we lean on throughout, re-stated in plain words:

The picture below is the whole game: a bell curve (the distribution of the random variable under ), your one observed value marked on it, and the shaded tail area = the p-value.

Figure — Hypothesis testing and p-values

Everything from here is: find , shade the right region, read the area. See 1.3.15-Central-limit-theorem for why is bell-shaped at all, and 1.3.1-Random-variables-and-distributions for what "random variable" and "distribution" mean.


Cell A — Two-tailed, positive effect


Cell B — Two-tailed, negative effect


Cell C — One-tailed, right side


Cell D — One-tailed, effect in the WRONG direction


Cell E — The exact boundary: p-value


Cell F — Degenerate input: observation equals the null


Cell G — Limiting case: huge sample size


Cell H — Real-world word problem (you build the hypotheses)


Cell I — Exam twist: run the machine backwards


Wrapping the matrix

Every cell of the scenario matrix is now a solved example. The single skill underneath all nine:

The only judgement calls are how many tails (from 's wording) and which side (from the sign of the effect). Get those two right and the arithmetic is identical every time.

Recall Quick self-test

Two-tailed : what is the p-value? ::: — the sign folds into . One-tailed right test, but the effect went the wrong way (): can you ever reject? ::: No — the right-tail p-value will exceed ; a wrong-direction effect is never evidence for . Observation exactly equals the null: what is and the p-value? ::: , p-value (two-tailed) — maximally boring. Why does a effect reject at but not ? ::: SE shrinks like , so grows with even when the effect is fixed. What's the difference between , , and ? ::: is the true unknown proportion; is the value claims; is what the sample showed. What's the difference between capital and lowercase ? ::: is the random variable (the whole bell); is the single observed number our data produced.

See also 1.3.21-Type-I-and-Type-II-errors (what "reject" costs you when was true) and 2.5.7-Statistical-significance-in-experiments (how these tests power real A/B decisions).