4.9.20 · D3Probability Theory & Statistics

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

2,406 words11 min readBack to topic

This page is a shooting range: every kind of hypothesis-test question the topic can fire at you, one after another, fully worked. We start by drawing the map of all cases, then walk each cell with a picture-first, guess-first method. Everything here builds on the parent Hypothesis testing — null - alternative, test statistic, p-value, errors (Type I & II) and leans on Central Limit Theorem, Standard Error, Normal Distribution and the Student t-distribution.

Before a single symbol appears, here is the plain-words dictionary we will keep re-using, so nothing is ever "assumed":


The scenario matrix

Every question in this topic is one row of this table. The examples below tick off every cell.

# Case class What changes Example that hits it
A Two-tailed, known z direction Ex 1
B Right-tailed, known z direction , statistic positive Ex 2
C Left-tailed, unknown t direction , statistic negative Ex 3
D Boundary / degenerate: exactly, and so zero input Ex 4
E Non-rejection read correctly (absence of evidence) large p-value Ex 5
F Limiting behaviour: same effect, growing → power rises Ex 6
G Type-II / power computation compute Ex 7
H Real-world word problem (proportions) different data type Ex 8
I Exam twist: they hand you the p-value and ask a trap question conceptual Ex 9

The three signs of the test statistic — positive, negative, zero — are covered by B, C, D. The three tail directions — two-tailed, right, left — are A, B, C. Good coverage means: no student hits a case we skipped.


Ex 1 — Case A: two-tailed z-test (both signs matter)

Forecast: guess first — is ml below target across 64 bottles surprising, or normal wobble? Jot a yes/no before reading on.

Step 1. Write , . Why this step? "Miscalibrated" says nothing about direction — too full is as bad as too empty — so both tails count. That is what means.

Step 2. Standard error ml. Why this step? The sample mean wobbles less than a single bottle because averaging cancels noise; the Central Limit Theorem says that wobble equals . See Standard Error.

Step 3. . Why this step? We convert "3 ml below" into "3 wobbles below," a unit-free count. Look at figure s01: the observed mean sits 3 tick-marks left of centre.

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

Step 4. Two-tailed p-value . Why this step? "As extreme or more" for means either far-left or far-right, so we take one tail's area and double it (the Normal Distribution is symmetric).

Step 5. reject . The machine is off.

Verify: SE units are ml (), is unitless (ml/ml) ✓. A of is famously rare (the "0.13%" tail), and doubling gives — matches intuition that a 3-wobble miss is a red flag.


Ex 2 — Case B: right-tailed z-test (positive statistic)

Forecast: 2 minutes over, 100 people. Reject or not? Guess.

Step 1. , . Why this step? The suspicion has a direction ("longer") → right tail only. We ignore the left tail entirely.

Step 2. min.

Step 3. . Why this step? Positive because sits above the claim — the sign of literally records "which side."

Step 4. Right-tailed p-value . Why this step? Only the right tail is "as extreme or more" when points right. No doubling here (contrast Ex 1).

Step 5. reject : evidence commutes are longer.

Verify: Same would give a two-tailed p of — still significant, but larger, showing the one-tailed test is more powerful in the pre-chosen direction. Units: min/min = unitless ✓.


Ex 3 — Case C: left-tailed t-test (negative statistic, σ unknown)

Forecast: small sample, 1.5 kg under. Reject?

Step 1. , (left tail — "underweight" points left).

Step 2. Why and not ? We do not know the true spread ; we only have the sample estimate . Estimating the spread adds extra uncertainty, so we use the fatter-tailed Student t-distribution with .

Step 3. kg.

Step 4. . Why this step? Negative = below claim, matching the left-tail suspicion.

Step 5. Critical value (right side); for a left tail we compare to . Since , we are farther out than the cutoff reject .

Verify: With , the one-sided p-value of is about ✓ — agrees with the critical-value decision. Two ways, same verdict.


Ex 4 — Case D: the degenerate boundary ( and )

Forecast: what should the test say when your data lands dead on the claim?

Step 1 (a). . Why this step? Zero distance → zero wobbles. The data is the least surprising it could possibly be.

Step 2 (a). Two-tailed . Why this step? Every possible dataset is "as extreme or more" than the exact centre, so the whole probability mass qualifies → . We fail to reject — as we must.

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

Step 3 (b). For two-tailed we need , i.e. , giving the famous . Why this step? This is the razor's edge. The convention is: at exactly we reject (the rule is ). So is the smallest that still rejects.

Verify: (a) ✓. (b) so doubled ✓ — the critical value is recovered exactly.


Ex 5 — Case E: a correct non-rejection (absence of evidence)

Forecast: does 1 point above prove the method works?

Step 1. , (right tail).

Step 2. .

Step 3. , .

Step 4. Critical . Since fail to reject .

Step 5 — the wording that scores marks. We did not prove the method useless. A 1-point rise on only 16 students is well inside luck's reach; a bigger might still reveal a real effect. This is absence of evidence, not evidence of absence.

Verify: The one-sided p-value for , is about — huge, nowhere near ✓. Consistent with "shrug and keep believing ."


Ex 6 — Case F: limiting behaviour, grow to infinity

Forecast: does a fixed 2-minute gap become more or less significant as data piles up?

Step 1. . Why this step? Fix the numerator; only SE shrinks. Writing as a function of exposes the trend.

Step 2. Plug in:

Step 3 — the limit. As , , so . Why this step? A real gap of any size becomes detectable once you gather enough data — SE narrows the null curve to a spike. Look at figure s03: the null bell tightens as climbs.

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

Verify: (not significant, two-tailed), (significant), (wildly significant) ✓. Confirms: statistical significance for a fixed effect is bought with sample size — see Statistical Power & Sample Size.


Ex 7 — Case G: computing a Type II error and power

Forecast: if the true mean is 6 above, how likely are we to miss it?

Step 1 — the reject region in real units. . We reject when , i.e. when . Why this step? is about the real-unit cutoff, so we translate the -cutoff back into an threshold. Here is the one-tailed 5% critical z.

Step 2 — evaluate under the truth. If really , the mean is Normal centred at with the same . A miss (Type II) happens when : Why this step? — measured under the true distribution, not the null. See figure s04: the amber "true" bell overlaps the accept region.

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

Step 3. Power .

Verify: -cutoff back-check: ✓. Miss z: , and ✓. Power — modest, as expected for a 2-SE-sized true effect. Larger or effect would raise it (Statistical Power & Sample Size, Confidence Intervals).


Ex 8 — Case H: real-world word problem (a proportion, the coin)

Forecast: 62 heads out of 100 — fluke or bias?

Step 1. , .

Step 2 — SE for a proportion. Under , each flip has variance , so . Why this step? We compute SE using the null value , because the whole test lives inside the "if were true" world.

Step 3. .

Step 4. reject : evidence of bias toward heads.

Verify: SE , , tail ✓. The Central Limit Theorem justifies treating as approximately Normal here since and are both large.


Ex 9 — Case I: the exam twist (they hand you the p-value)

Forecast: does measure the probability the null is true? Decide before reading.

Step 1 — name the trap. The claim confuses with . This is the prosecutor's fallacy. Why this step? is computed assuming true — you cannot then read it as 's own probability; that would require a prior, which lives in Bayesian Inference.

Step 2 — state it right. "" means: *if were true, data this extreme (or more) would occur only 3% of the time." It says nothing directly about .

Step 3 — the correct decision. Since , we reject . Correct verdict, wrong reasoning by the classmate.

Verify: Logic check only — the numeric comparison is true, so "reject" is the right action; the interpretation is the error. ✓


Recall Self-test: which cell is this?

"Testing whether a mean is different (either way) with known ." ::: Case A — two-tailed z (Ex 1). "Data lands exactly on ; what is the two-tailed p-value?" ::: Case D — , fail to reject (Ex 4). "Same effect size, ever-larger : what happens to ?" ::: Case F — ; a fixed effect always becomes significant (Ex 6). "Given the true mean, find the chance of missing it." ::: Case G — compute , power (Ex 7). "Someone says p is the probability is true." ::: Case I — prosecutor's fallacy; (Ex 9).