Hypothesis tests for a mean (σ known)
Is the drug better, or was it luck?
Five steps turn one sample into a decision you can defend.
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Anonymous check
Of the drugs that pass, about how many actually do nothing?
A simplified, fictional regulator approves every drug whose trial passes a test at the 5% level. Suppose 10% of the drugs sent in truly work, and a working drug passes 80% of the time. A drug that does nothing passes 5% of the time, by luck alone.
-
About 5%
-
About 20%
-
About 35%
-
Over 50%
Vote by phone or A–D card. We count it out later today.
C1 · the logic of a test
A test works like a trial.
Start from a default claim. Give it up only if the evidence would be surprising were it true.
| Criminal trial | Hypothesis test | |
|---|---|---|
| Default | The defendant is innocent. | \(H_0\): no effect. For the drug, \(\mu = 14\) days. |
| Burden | Evidence beyond reasonable doubt. | Data that would be rare if \(H_0\) were true: \(p < \alpha\). |
| Verdicts | Guilty · not guilty | Reject \(H_0\) · fail to reject \(H_0\) |
“Not guilty” does not mean innocent. “Fail to reject \(H_0\)” does not mean \(H_0\) is true.
C2 · every test in this course
The same five steps, every time.
The details change from test to test. The steps do not.
- State \(H_0\) and \(H_a\). Parameter, claimed value, direction. Choose \(\alpha\) now, before the data.
- Check conditions. Independence; shape or sample size; \(\sigma\) known. If one fails, stop.
- Compute the test statistic. \(z = \dfrac{\bar{x} - \mu_0}{\sigma / \sqrt{n}}\)
- Find the p-value. The z-table and the direction of \(H_a\) give the tail area.
- Conclude in context. \(p < \alpha\): reject \(H_0\). Otherwise: fail to reject \(H_0\). Never “accept”.
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Expert model · the drug trial
Step 1: what are we testing?
Industry-standard recovery: 14 days. The company claims its drug brings the mean below 14. Trial: a random sample of \(n = 49\) patients, \(\bar{x} = 12.8\) days, \(\sigma = 4.2\) days from long records.
- Null\(H_0: \mu = 14\) days the default: no improvement
- Alternative\(H_a: \mu < 14\) days the claim, so left-tailed
- Level\(\alpha = 0.05\) fixed now, before any data
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Expert model · the drug trial
Step 2: may we use the z-test?
Trial: a random sample of \(n = 49\) patients, \(\bar{x} = 12.8\) days, \(\sigma = 4.2\) days from long records.
- Independent49 patients, randomly selected, one result each
- Shape\(n = 49 \ge 30\), so \(\bar{x}\) is close to normal
- σ known\(\sigma = 4.2\) from long records → z-test
If a condition fails, stop: this test does not apply.
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Expert model · the drug trial
Step 3: how far is 12.8 from 14?
If \(H_0\) is true, sample means of 49 patients centre on 14 days, with standard error \(\sigma/\sqrt{n}\).
- \(\text{SE} = \dfrac{4.2}{\sqrt{49}} = \dfrac{4.2}{7} = 0.6\)
- \(z = \dfrac{12.8 - 14}{0.6} = \dfrac{-1.2}{0.6}\)
- \(z = -2.00\): two standard errors below 14
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
C4 · the p-value
Step 4: how often would luck do this?
p-value: the probability of a result at least as extreme as ours, if \(H_0\) is true.
If the drug did nothing, about 2 trials in 100 would look this good by luck alone.
It is not the chance that the drug does nothing.
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Expert model · the drug trial
Step 4: how surprising is z = −2.00?
Step 3 gave \(z = -2.00\). \(H_a: \mu < 14\), so the p-value is the area to the left of \(-2.00\).
| z | .00 | .01 | .02 | .03 | .04 |
|---|---|---|---|---|---|
| 1.8 | 0.9641 | 0.9649 | 0.9656 | 0.9664 | 0.9671 |
| 1.9 | 0.9713 | 0.9719 | 0.9726 | 0.9732 | 0.9738 |
| 2.0 | 0.9772 | 0.9778 | 0.9783 | 0.9788 | 0.9793 |
| 2.1 | 0.9821 | 0.9826 | 0.9830 | 0.9834 | 0.9838 |
| 2.2 | 0.9861 | 0.9864 | 0.9868 | 0.9871 | 0.9875 |
- Row 2.0: z to one decimal
- Column .00: second decimal
- P(Z < 2.00) = 0.9772
- The table lists positive z only. By symmetry:
- \(P(Z \le -2.00) = 1 - P(Z < 2.00)\)
- \(= 1 - 0.9772 = 0.0228\)
- p-value = 0.0228
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Expert model · the drug trial
Step 5: decide, then say it in context.
\(p = 0.0228\), and \(\alpha = 0.05\) was fixed in step 1.
- \(p = 0.0228 < 0.05 = \alpha\)
- Reject \(H_0\).
- At the 5% level, the trial gives evidence that the drug’s mean recovery time is below 14 days.
Evidence, not proof. And never “accept \(H_0\)”.
Anonymous check
Which statement about p = 0.04 is correct?
A tutoring program is tested against the claim that it has no effect on test scores. The study finds a gain, with a p-value of 0.04.
-
If the program had no effect, about 4% of studies like this would show a gain at least this large
-
There is a 4% chance that the program has no effect
-
There is a 96% chance that the program works
-
There is a 4% chance that the result is due to chance
Vote by phone or A–D card.
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Expert model · complete
The drug trial, five lines.
- \(H_0: \mu = 14\), \(H_a: \mu < 14\), \(\alpha = 0.05\)
- Random, independent; \(n = 49 \ge 30\); \(\sigma = 4.2\) known
- \(\text{SE} = 0.6\), \(z = (12.8 - 14)/0.6 = -2.00\)
- Left tail: \(p = 1 - P(Z < 2.00) = 1 - 0.9772 = 0.0228\)
- \(0.0228 < 0.05\): reject \(H_0\); evidence the mean is below 14 days
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
C5 · C6 · one z, three alternatives
The same z, three different p-values.
Suppose a test gives \(z = -1.73\). The p-value depends on the direction of \(H_a\), chosen in step 1, before the data.
\(H_a: \mu < \mu_0\) · left tail
\(H_a: \mu > \mu_0\) · right tail
\(H_a: \mu \ne \mu_0\) · both tails
\(p = 2\,(1 - P(Z < 1.73)) = 2(0.0418) = 0.0836\)
Anonymous check
Which alternative hypothesis leads to rejecting H₀?
A test gives z = −1.85 at the 5% level. Table: P(Z < 1.85) = 0.9678.
| z | .04 | .05 | .06 |
|---|---|---|---|
| 1.7 | 0.9591 | 0.9599 | 0.9608 |
| 1.8 | 0.9671 | 0.9678 | 0.9686 |
| 1.9 | 0.9738 | 0.9744 | 0.9750 |
P(Z < 1.85) = 0.9678
-
Hₐ: μ < μ₀ only
-
Hₐ: μ ≠ μ₀ only
-
Hₐ: μ > μ₀ only
-
All three
Anonymous check
Which hypotheses belong in step 1?
A coffee machine is set to fill a mean of 250 mL; the maker’s specification gives a population standard deviation of 6 mL. An inspector checks, at a 5% significance level, whether the mean fill is off target in either direction: a random sample of 36 cups has a sample mean of 252.3 mL.
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
-
H₀: μ = 250, Hₐ: μ ≠ 250
-
H₀: μ = 250, Hₐ: μ > 250
-
H₀: μ = 252.3, Hₐ: μ ≠ 252.3
-
H₀: μ ≠ 250, Hₐ: μ = 250
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Problem B · coffee machine · you do the transform
Steps 2 and 3, then read the table.
\(H_a: \mu \ne 250\) · \(\sigma = 6\) · \(n = 36\) · \(\bar{x} = 252.3\) · \(\alpha = 0.05\)
- Random cups; \(n = 36 \ge 30\); \(\sigma\) known
- \(\text{SE} = 6/\sqrt{36} = 1\)
- \(z = (252.3 - 250)/1 = 2.30\)
| z | .00 | .01 | .02 | .03 | .04 |
|---|---|---|---|---|---|
| 2.1 | 0.9821 | 0.9826 | 0.9830 | 0.9834 | 0.9838 |
| 2.2 | 0.9861 | 0.9864 | 0.9868 | 0.9871 | 0.9875 |
| 2.3 | 0.9893 | 0.9896 | 0.9898 | 0.9901 | 0.9904 |
| 2.4 | 0.9918 | 0.9920 | 0.9922 | 0.9925 | 0.9927 |
| 2.5 | 0.9938 | 0.9940 | 0.9941 | 0.9943 | 0.9945 |
- Row 2.3: z to one decimal
- Column .00: second decimal
- P(Z < 2.30) = 0.9893
Anonymous check
What is the p-value?
Coffee machine: Hₐ: μ ≠ 250, z = 2.30, and the z-table gives P(Z < 2.30) = 0.9893.
-
0.0214
-
0.0107
-
0.9893
-
0.4893
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Problem B · coffee machine
Step 5, in context.
\(p = 2(1 - 0.9893) = 0.0214\), \(\alpha = 0.05\)
- \(0.0214 < 0.05\): reject \(H_0\)
- At the 5% level, the data give evidence that the mean fill differs from 250 mL.
At \(\alpha = 0.01\) the same data would not reject.
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Problem C · road sensor · you write steps 1 and 2
Write steps 1 and 2 on paper.
Before collecting data, a city planned to test, at a 5% significance level, whether the mean speed on a road is above the 100 km/h limit. Long records give a population standard deviation of 8 km/h. A random sample of 64 cars has a sample mean of 101.5 km/h.
- \(H_0: \mu = 100\), \(H_a: \mu > 100\) (right tail), \(\alpha = 0.05\)
- Random cars; \(n = 64 \ge 30\); \(\sigma = 8\) known
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Problem C · road sensor · name the cell first
Which cell do we read?
\(H_a: \mu > 100\) · \(\sigma = 8\) · \(n = 64\) · \(\bar{x} = 101.5\)
- \(\text{SE} = 8/\sqrt{64} = 1\)
- \(z = (101.5 - 100)/1 = 1.50\)
| z | .00 | .01 | .02 | .03 | .04 |
|---|---|---|---|---|---|
| 1.3 | 0.9032 | 0.9049 | 0.9066 | 0.9082 | 0.9099 |
| 1.4 | 0.9192 | 0.9207 | 0.9222 | 0.9236 | 0.9251 |
| 1.5 | 0.9332 | 0.9345 | 0.9357 | 0.9370 | 0.9382 |
| 1.6 | 0.9452 | 0.9463 | 0.9474 | 0.9484 | 0.9495 |
| 1.7 | 0.9554 | 0.9564 | 0.9573 | 0.9582 | 0.9591 |
- Row 1.5: z to one decimal
- Column .00: second decimal
- P(Z < 1.50) = 0.9332
- Right tail: \(p = 1 - P(Z < 1.50)\)
- \(= 1 - 0.9332 = 0.0668\)
Anonymous check
Which conclusion may the city write?
Road sensor: H₀: μ = 100, Hₐ: μ > 100 km/h, α = 0.05. The test gives p = 0.0668.
-
Fail to reject H₀: not enough evidence that the mean speed is above 100 km/h
-
Accept H₀: the mean speed is 100 km/h
-
There is a 6.68% chance that the mean speed is 100 km/h
-
A Type I error occurred
Anonymous check
What is the p-value?
Hₐ: μ > μ₀ was written before the data. The sample gives z = −1.30. From the z-table, P(Z < 1.30) = 0.9032.
| z | .00 | .01 | .02 |
|---|---|---|---|
| 1.2 | 0.8849 | 0.8869 | 0.8888 |
| 1.3 | 0.9032 | 0.9049 | 0.9066 |
| 1.4 | 0.9192 | 0.9207 | 0.9222 |
P(Z < 1.30) = 0.9032
-
0.9032
-
0.0968
-
0.1936
-
Switch to Hₐ: μ < μ₀, so p = 0.0968
C7 · errors and power
Every decision can be wrong in one way.
Columns: what is really true. Rows: what the test decides.
| \(H_0\) true (no effect) | \(H_0\) false (real effect) | |
|---|---|---|
| Reject \(H_0\) | Type I errorfalse alarm · rate \(\alpha\) | Correctpower \(= 1 - \beta\) |
| Fail to reject | Correctrate \(1 - \alpha\) | Type II errora miss · rate \(\beta\) |
Anonymous check
What happened?
A new drug truly shortens recovery time. Its trial, at a 5% significance level, fails to reject the null hypothesis.
-
A Type II error
-
A Type I error
-
A correct decision
-
No error: failing to reject makes no claim
The opening question, counted out
Of the drugs that pass, how many do nothing?
Suppose 1,000 drugs reach the regulator, 10% of them truly work, the test catches a working drug 80% of the time (power 0.80) and α = 0.05.
125 pass, and 45 of them do nothing: \(45/125 = 36\%\). About 35% (C).
Anonymous check
What happens to power?
The drug trial again: 49 patients, and suppose the drug really shortens recovery by one day. At a 5% significance level, power is about 0.51. The regulator lowers the significance level to 1%, with the same 49 patients.
-
Power falls
-
Power rises: a stricter test is a better test
-
No change: α only controls Type I errors
-
Power becomes 0.99
C8 · Figure 6 from the lesson
A stricter α costs power.
Drug trial, left-tailed. Solid: \(H_0\) true (14 days). Dashed: the drug works (13 days).
C8 · Figure 7 from the lesson
Significant is not the same as important.
Two trials of the same kind of drug, both against 14 days.
| Trial | Patients | Mean recovery | Benefit | p-value |
|---|---|---|---|---|
| 1 | \(n = 49\) | 12.8 days | 1.2 days | \(\approx 0.023\) |
| 2 | \(n = 10\,000\) | 13.9 days | 0.1 day | \(\approx 0.009\) |
The smaller p-value comes with the smaller benefit. Report the size of the effect beside p: 0.1 day (about 2.4 hours) may not matter to anyone.
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Problem D · ambulance dispatch · you do steps 1 to 3
Steps 1 to 3 on paper, then check.
Before a new dispatch system was rolled out, the city set a goal: a mean response time shorter than 9.0 minutes, tested at a 1% significance level. Long records give a population standard deviation of 2.0 min. A random sample of 100 calls has a sample mean of 8.55 min.
- \(H_0: \mu = 9.0\), \(H_a: \mu < 9.0\), \(\alpha = 0.01\)
- Random calls; \(n = 100 \ge 30\); \(\sigma = 2.0\) known
- \(\text{SE} = 2.0/\sqrt{100} = 0.2\), \(z = (8.55 - 9.0)/0.2 = -2.25\)
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Problem D · find the cell yourself
Find the cell, then decide.
\(H_a: \mu < 9.0\) · \(z = -2.25\) · \(\alpha = 0.01\), fixed before the data
| z | .03 | .04 | .05 | .06 | .07 |
|---|---|---|---|---|---|
| 1.9 | 0.9732 | 0.9738 | 0.9744 | 0.9750 | 0.9756 |
| 2.0 | 0.9788 | 0.9793 | 0.9798 | 0.9803 | 0.9808 |
| 2.1 | 0.9834 | 0.9838 | 0.9842 | 0.9846 | 0.9850 |
| 2.2 | 0.9871 | 0.9875 | 0.9878 | 0.9881 | 0.9884 |
| 2.3 | 0.9901 | 0.9904 | 0.9906 | 0.9909 | 0.9911 |
- \(P(Z < 2.25) = 0.9878\)
- \(p = 1 - 0.9878 = 0.0122\)
- \(0.0122 \ge 0.01\): fail to reject \(H_0\)
It would reject at 0.05. But α was fixed at 0.01 before the data, so the data do not show that the goal was met.
- ?
- ?
- ?
- ?
- ?
Problem E · on your own
Run all five steps on paper.
A bakery labels its loaves 800 g. Long records give a population standard deviation of 15 g. Inspectors test, at a 5% significance level, whether the mean weight differs from 800 g. A random sample of 81 loaves has a sample mean of 797.0 g.
| z | .00 | .01 | .02 | .03 | .04 |
|---|---|---|---|---|---|
| 1.7 | 0.9554 | 0.9564 | 0.9573 | 0.9582 | 0.9591 |
| 1.8 | 0.9641 | 0.9649 | 0.9656 | 0.9664 | 0.9671 |
| 1.9 | 0.9713 | 0.9719 | 0.9726 | 0.9732 | 0.9738 |
| 2.0 | 0.9772 | 0.9778 | 0.9783 | 0.9788 | 0.9793 |
| 2.1 | 0.9821 | 0.9826 | 0.9830 | 0.9834 | 0.9838 |
- Hypotheses
- Conditions
- Statistic
- p-value
- Conclude
Problem E · check your five lines
Compare line by line.
Loaves: \(\sigma = 15\), \(n = 81\), \(\bar{x} = 797.0\), \(\alpha = 0.05\)
- \(H_0: \mu = 800\), \(H_a: \mu \ne 800\), \(\alpha = 0.05\)
- Random loaves; \(n = 81 \ge 30\); \(\sigma\) known
- \(\text{SE} = 15/9 \approx 1.667\), \(z = (797.0 - 800)/1.667 = -1.80\)
- \(p = 2(1 - P(Z < 1.80)) = 2(1 - 0.9641) = 0.0718\)
- \(0.0718 \ge 0.05\): fail to reject; no evidence the mean differs from 800 g
A second view: the 95% interval \(797.0 \pm 1.96(1.667) = (793.7,\ 800.3)\) contains 800, and also 795 and 799. Failing to reject does not show the mean is 800.
The drug trial, one last time
What p = 0.0228 said, and what it did not.
Said: if the drug did nothing, a trial this good would happen about 2 times in 100.
Did not say: the chance the drug is a dud. In our inbox, 36% of the drugs that passed did nothing, and that depended on how many drugs work.
Anonymous check
What are the p-value and the decision?
A test has Hₐ: μ > μ₀ and gives z = 1.80, with α = 0.05. From the z-table, P(Z < 1.80) = 0.9641.
-
p = 0.0359, reject H₀
-
p = 0.0718, fail to reject H₀
-
p = 0.9641, fail to reject H₀
-
P(H₀ is true) = 0.0359, reject H₀
Anonymous check
What happened?
A new drug truly does nothing, but its trial rejects H₀ at α = 0.05.
-
A Type I error
-
A Type II error
-
A correct decision
-
Low power
Anonymous check
How confident are you that you could run all five steps on your own?
Think of a fresh problem: a claimed mean, σ known, a random sample.
-
Confident: I could do it now
-
Mostly: I would check one step
-
Unsure about the table or the tail
-
Not yet