1.3.20 · D4Probability & Statistics

Exercises — Hypothesis testing and p-values

2,385 words11 min readBack to topic

Before we start, one picture to keep in your head the whole way down — the "extremeness" idea that a p-value measures.

Figure — Hypothesis testing and p-values

Level 1 — Recognition

L1.1

State, for each pair, which is the null and which is the alternative : (a) "the coin is fair" vs "the coin is biased"; (b) "the new model is no better than 82%" vs "the new model beats 82%".

Recall Solution

The null is always the boring, no-effect, equality statement. (a) (fair). (biased) — two-sided because "biased" could go either way. (b) (no improvement). (better) — one-sided because we only care about better.

L1.2

A test gives a p-value of and you chose . Do you reject or fail to reject ? Then repeat for a p-value of .

Recall Solution

Rule: reject when .

  • reject .
  • fail to reject (not "accept").

L1.3

Which of these is the correct reading of ""? (A) "There is a 3% chance is true." (B) "If were true, data this extreme (or more) would occur 3% of the time."

Recall Solution

(B). The p-value is , never . Statement (A) reverses the conditioning.


Level 2 — Application

L2.1

You flip a coin times and see heads. Test vs . Compute the z-statistic.

Recall Solution

Under , , so The z-statistic counts standard deviations from the mean:

L2.2

Continuing L2.1, the standard normal gives . What is the two-tailed p-value, and what do you decide at ?

Recall Solution

Two-tailed because counts extremeness on both sides: Since , reject — but only just. Look at the figure below: our lands right at the edge of the shaded region.

Figure — Hypothesis testing and p-values

L2.3

A new model scores accuracy on samples. Old accuracy is . Test vs (one-tailed). Find and the one-tailed p-value ().

Recall Solution

Standardise the observed proportion using the null's standard error: One-tailed p-value: . Since , reject — the model is significantly better.


Level 3 — Analysis

L3.1

In L2.2 you rejected with . Suppose instead you had pre-declared a one-tailed test . What would the p-value be, and would the decision change? Explain what this reveals.

Recall Solution

One-tailed p-value: . That is exactly half the two-tailed value. Decision: reject (still , now more comfortably). What it reveals: the same data can be "more significant" simply by choosing one tail. This is why you must pick one-vs-two-tailed before seeing the data — otherwise you can nudge yourself past the threshold. Halving the p-value by switching tails after the fact is a form of p-hacking.

L3.2

Two labs test the same fair coin. Lab A flips it times, Lab B flips times. Both observe a proportion of heads equal to . Compute both z-statistics and comment on why the "same" result gives different conclusions.

Recall Solution

. Lab A: , so . Two-tailed → fail to reject. Lab B: , so . astronomically small → reject. Comment: the effect ( vs ) is identical, but larger shrinks the standard error, so the same effect becomes overwhelmingly "significant." Statistical significance is not the same as a large or important effect — it grows with sample size (see the drug example in the parent's Mistake 3).

L3.3

The die test in the parent note gave with and . Recompute if every observed count were exactly the expected . Interpret the resulting p-value.

Recall Solution

Each term , so . A perfectly-fitting sample is as un-extreme as possible, so the tail probability , i.e. . Interpretation: does not prove the die is fair — it just means the data is maximally consistent with fairness. "Consistent with " is never " proven."


Level 4 — Synthesis

L4.1

You run a z-test at (two-tailed). The rejection region is where . (a) Explain how is defined. (b) Show that "reject " is equivalent to "the confidence interval for the mean excludes ."

Recall Solution

(a) is the value putting in each tail: , so together the two tails hold exactly . (b) The two-tailed test rejects when The confidence interval is . It excludes exactly when — the same inequality. So a two-sided test at level and a confidence interval are two views of one machine (see 1.3.18-Confidence-intervals).

L4.2

Design decision: an A/B test where a false positive (shipping a useless model) is very costly, but a false negative (missing a good model) is cheap. Should you make smaller or larger than ? Explain using Type I / Type II errors.

Recall Solution

is the Type I error rate (false positive). Since false positives are the expensive mistake, lower (e.g. ). Trade-off: lowering raises (Type II, false negatives) and lowers power — but here false negatives are cheap, so that's acceptable. See 1.3.21-Type-I-and-Type-II-errors.

L4.3

Compute the power of a one-tailed z-test (, so reject when ) for detecting a coin with true using flips, testing . Use the approximation that under , .

Recall Solution

Reject when (using null SE ). Power . Under , SE . Power . So this test has about a 64% chance of catching a genuinely biased () coin. Not great — you'd want a larger to raise power.


Level 5 — Mastery

L5.1

You run 20 independent hypothesis tests, each at , on data where every is actually true. What is the probability of at least one false rejection? What single fix reduces this?

Recall Solution

Each test has a chance of a false positive, so a chance of no false positive. Independent, so: About a 64% chance you "discover" something that isn't real! This is the multiple-comparisons problem. Fix: a multiple-testing correction such as Bonferroni — test each at . See 3.2.12-Multiple-testing-correction.

L5.2

After the Bonferroni fix in L5.1 (per-test level ), recompute the family-wide false-positive probability. Did it drop below ?

Recall Solution

Per-test survival . Yes — Bonferroni pulls the family-wide false-positive rate back under , at the cost of lower power on each individual test.

L5.3

A drug trial reports but the average symptom reduction is with a CI of . A journalist writes "highly significant → this drug is a breakthrough." As the resident statistician, write the two-sentence correction.

Recall Solution

"The tiny p-value only means the effect is very unlikely to be pure chance — with a large enough trial even trivial effects reach significance. The effect size itself (, CI ) is clinically negligible, so 'statistically significant' here does not mean 'clinically important' — statistical and practical significance are different things (see 2.5.7-Statistical-significance-in-experiments)."


Recall One-line self-quiz (reveal each)

When is a p-value two-tailed? ::: When is "" — extreme in either direction, so you double the one-tail area. Reject or not if , ? ::: Reject (just barely, since ). Why does the same effect get "more significant" with bigger ? ::: Standard error shrinks like , so grows. What does power measure? ::: , the chance of correctly rejecting a false . Bonferroni per-test level for 20 tests at family ? ::: .