4.9.20 · D2Probability Theory & Statistics

Visual walkthrough — Hypothesis testing — null - alternative, test statistic, p-value, errors (Type I & II)

1,944 words9 min readBack to topic

Here is the whole plan in one glance. Read it, then we build every box.

we measure a few bottles

average them into X-bar

X-bar wobbles run to run

measure the wobble = standard error

assume boring story true mu = mu-zero

count how many wobbles away we are = Z

compare Z to the bell curve

too far out means reject the boring story


Step 1 — One measurement is a noisy dart

WHAT. We have a machine that is supposed to fill each bottle to some target amount. We call one measured fill . Measure another and we get , and so on up to , where is just "how many bottles we checked" (a plain counting number like ).

Each single measurement is a noisy dart: even a perfect machine never pours exactly the same amount twice. Two invented words describe that noise:

WHY these two. A dartboard is fully summarised by where the cloud sits () and how wide it is (). Nothing else about the noise matters for what follows.

PICTURE. The scattered pale-blue darts below have a centre (yellow line ) and a spread (the pink band ).

Figure — Hypothesis testing — null - alternative, test statistic, p-value, errors (Type I & II)

Step 2 — Averaging many darts calms the wobble

WHAT. Instead of trusting one noisy dart, we average all of them into a single number, the sample mean:

Read as "X-bar." The bar means "averaged." The symbol is a stack of instructions: start at , add , step up by one, stop after — i.e. .

WHY average. One dart is jumpy; the average of many darts barely moves, because a high fill here tends to cancel a low fill there. Averaging is our noise-reducer.

PICTURE. Left: single darts, wide scatter. Right: their averages , a tight cluster hugging the same centre. Same centre, smaller spread — that is the whole point.

Figure — Hypothesis testing — null - alternative, test statistic, p-value, errors (Type I & II)

Step 3 — Exactly how much calmer? The variance shrinks by

WHAT. We now measure how much the averaging calmed things down. Two facts, each earned:

  • : the average of the averages sits on the same centre. Averaging does not move the target, it only sharpens it.
  • : the spread of is the single-dart spread divided by .

WHY the . For independent darts, variances of a sum add: . But multiplies that sum by the constant , and a constant pulls out of variance squared: . So

The from squaring the constant beats the from adding — net shrink by . This is the seed of the Central Limit Theorem and of Standard Error.

PICTURE. Three bell shapes for : same centre , each half as wide as quadruples (because width ).

Figure — Hypothesis testing — null - alternative, test statistic, p-value, errors (Type I & II)

Step 4 — Name the wobble: standard error

WHAT. The spread of in original units deserves its own name — the standard error:

  • = spread of one dart (millilitres).
  • = how much averaging tightened it.
  • = spread of (also millilitres) — our yardstick.

WHY square-root. Variance lives in squared units (ml); to compare against a mean in ml we must take the square root to return to ml. See Standard Error for more.

PICTURE. The wide dart-cloud (spread ) beside the narrow average-cloud (spread ), with a labelled bracket showing .

Figure — Hypothesis testing — null - alternative, test statistic, p-value, errors (Type I & II)

Step 5 — Assume the boring story, then measure the gap

WHAT. The "boring story" is a specific claimed centre, (mu-nought) — e.g. "the machine really pours ml on average." This is the null hypothesis . We assume it true and look at the gap between what we saw and what it predicts:

  • = what we measured.
  • = what promised.
  • their difference = how far off the boring story is (in ml).

WHY assume . We need a fixed centre to measure against. The boring claim gives us that fixed pin; everything is judged relative to it. We are not saying is true — we are asking "if it were, how surprising is this gap?"

PICTURE. The bell of centred at (the assumption), with our observed marked off to the side and the raw gap drawn as a yellow arrow.

Figure — Hypothesis testing — null - alternative, test statistic, p-value, errors (Type I & II)

Step 6 — Measure the gap in yardsticks: the z-statistic

WHAT. A raw gap of " ml" is meaningless until we know whether ml is a lot or a little. So we divide the gap by the yardstick :

  • Numerator : the raw gap.
  • Denominator : one standard error.
  • : how many standard errors the data sits from — a pure number, no units.

WHY divide. Dividing a length by the same-unit yardstick cancels the units and answers "how many wobbles away am I?" means "three standard errors below the claim." Because of the Central Limit Theorem, this follows the standard normal — a fixed bell we can read probabilities off. (When is unknown and we substitute the sample spread , the same recipe gives on the fatter-tailed Student t-distribution.)

PICTURE. The standard normal bell on a ruler marked in standard errors , with 's raw gap being "measured" by stepping off three yardsticks to land at .

Figure — Hypothesis testing — null - alternative, test statistic, p-value, errors (Type I & II)

Step 7 — Read the surprise: shaded tail = p-value

WHAT. The p-value is the shaded area in the tail(s) beyond our under the standard bell:

  • : how far out we landed, ignoring sign.
  • : chance a fair (null-true) world coughs up something at least this extreme in one tail.
  • factor : for "" tests, extreme means either side, so shade both tails.

WHY area, why two tails. Area = probability. Since counts a suspiciously high fill as damning as a suspiciously low one, we shade both ends. A right-tailed test () shades one end; a left-tailed test () shades the other. Choosing the tail after peeking at the data is cheating — fix it beforehand.

PICTURE. The bell with both tails past shaded pink; the tiny shaded area is .

Figure — Hypothesis testing — null - alternative, test statistic, p-value, errors (Type I & II)

Step 8 — Edge & degenerate cases (never skip these)

WHAT / WHY / PICTURE for each corner the reader could hit:

  • exactly (): the data sits on the claim. is as large as it gets ( two-tailed). Zero surprise — never reject.
  • : . One dart, no averaging help — the widest possible bell. The method still runs, it is just weak.
  • : . The bell collapses to a spike; any nonzero gap gives a giant and rejects. A huge sample flags even a tiny, meaningless difference — statistical significance is not practical importance.
  • unknown: swap in sample spread , use on the Student t-distribution with degrees of freedom — fatter tails to pay for our uncertainty about the spread. For small this makes rejecting harder, as it should.
Figure — Hypothesis testing — null - alternative, test statistic, p-value, errors (Type I & II)

The one-picture summary

Everything on one board: darts → average → shrink by → yardstick → count yardsticks to → shade the tail for .

Figure — Hypothesis testing — null - alternative, test statistic, p-value, errors (Type I & II)
Recall Feynman: the whole walk in plain words

I throw a few darts (measurements). One dart is jumpy, so I average them — the average barely moves and clusters tighter around the same bullseye. I can measure how much tighter: the wobble shrinks by a factor of , and its size in real units is the standard error, . Now someone claims the bullseye is exactly . I pretend they're right, look at how far my average landed from , and measure that distance in wobble-widths — that number is . Finally I ask: if the claim were true, how often would pure luck fling me this far out? That chance is the shaded tail, the p-value. Tiny tail → "this basically never happens by luck" → I stop believing the claim. Big tail → "eh, happens" → I shrug and keep it. I never proved the ; I just failed to catch it lying.

Recall Rebuild the formula from the pictures

Spread of one dart? ::: (standard deviation). Spread of the average of darts? ::: . Why divide by in ? ::: To measure the gap in yardsticks (standard errors) so it becomes a unit-free, comparable number. Two-tailed p-value from ? ::: . What happens to as ? ::: It shrinks to ; the bell becomes a spike and almost any gap rejects.

Active Recall

What single number does report?
How many standard errors the sample mean sits from the null-claimed mean .
Why does and not ?
The constant pulls out of variance squared as ; times the summed variance gives .
If exactly, what is and the decision?
, largest possible p-value — never reject.
When must you switch from to ?
When is unknown and estimated by ; then .