L-INF-5 Introduction to Probability and Statistics

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.

  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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.

  1. About 5%

  2. About 20%

  3. About 35%

  4. 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.

  1. State \(H_0\) and \(H_a\). Parameter, claimed value, direction. Choose \(\alpha\) now, before the data.
  2. Check conditions. Independence; shape or sample size; \(\sigma\) known. If one fails, stop.
  3. Compute the test statistic. \(z = \dfrac{\bar{x} - \mu_0}{\sigma / \sqrt{n}}\)
  4. Find the p-value. The z-table and the direction of \(H_a\) give the tail area.
  5. Conclude in context. \(p < \alpha\): reject \(H_0\). Otherwise: fail to reject \(H_0\). Never “accept”.
  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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.

  1. Null\(H_0: \mu = 14\) days the default: no improvement
  2. Alternative\(H_a: \mu < 14\) days the claim, so left-tailed
  3. Level\(\alpha = 0.05\) fixed now, before any data
  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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.

  1. Independent49 patients, randomly selected, one result each
  2. Shape\(n = 49 \ge 30\), so \(\bar{x}\) is close to normal
  3. σ known\(\sigma = 4.2\) from long records → z-test

If a condition fails, stop: this test does not apply.

  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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}\).

  1. \(\text{SE} = \dfrac{4.2}{\sqrt{49}} = \dfrac{4.2}{7} = 0.6\)
  2. \(z = \dfrac{12.8 - 14}{0.6} = \dfrac{-1.2}{0.6}\)
  3. \(z = -2.00\): two standard errors below 14
12.2 −3 SE 12.8 −2 SE 13.4 −1 SE 14.0 z = 0 14.6 +1 SE 15.2 +2 SE 15.8 +3 SE x̄ = 12.8
sample mean x̄ (days), if H₀ is true
  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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.

12.2 12.8 13.4 14.0 14.6 15.2 15.8 about 2.3% our trial
sample mean x̄ (days), if the drug does nothing

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.

  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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\).

Excerpt of the z-table: P(Z < z), the area to the left of z. Rows give z to one decimal; columns give the second decimal.
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
  1. Row 2.0: z to one decimal
  2. Column .00: second decimal
  3. P(Z < 2.00) = 0.9772
  1. The table lists positive z only. By symmetry:
  2. \(P(Z \le -2.00) = 1 - P(Z < 2.00)\)
  3. \(= 1 - 0.9772 = 0.0228\)
  4. p-value = 0.0228
  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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.

  1. \(p = 0.0228 < 0.05 = \alpha\)
  2. Reject \(H_0\).
  3. 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.

  1. If the program had no effect, about 4% of studies like this would show a gain at least this large

  2. There is a 4% chance that the program has no effect

  3. There is a 96% chance that the program works

  4. There is a 4% chance that the result is due to chance

Vote by phone or A–D card.

  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. Conclude

Expert model · complete

The drug trial, five lines.

  1. \(H_0: \mu = 14\), \(H_a: \mu < 14\), \(\alpha = 0.05\)
  2. Random, independent; \(n = 49 \ge 30\); \(\sigma = 4.2\) known
  3. \(\text{SE} = 0.6\), \(z = (12.8 - 14)/0.6 = -2.00\)
  4. Left tail: \(p = 1 - P(Z < 2.00) = 1 - 0.9772 = 0.0228\)
  5. \(0.0228 < 0.05\): reject \(H_0\); evidence the mean is below 14 days
  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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

-3 -2 -1 0 1 2 3 p = P(Z < −1.73) = 0.0418 z = −1.73
z if H₀ is true

\(H_a: \mu > \mu_0\) · right tail

-3 -2 -1 0 1 2 3 p = 1 − P(Z < −1.73) = 0.9582 z = −1.73
z if H₀ is true

\(H_a: \mu \ne \mu_0\) · both tails

-3 -2 -1 0 1 2 3 0.0418 0.0418 z = −1.73
z if H₀ is true

\(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.

Excerpt of the z-table: P(Z < z), the area to the left of z. Rows give z to one decimal; columns give the second decimal.
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

  1. Hₐ: μ < μ₀ only

  2. Hₐ: μ ≠ μ₀ only

  3. Hₐ: μ > μ₀ only

  4. 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.

  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. Conclude
  1. H₀: μ = 250, Hₐ: μ ≠ 250

  2. H₀: μ = 250, Hₐ: μ > 250

  3. H₀: μ = 252.3, Hₐ: μ ≠ 252.3

  4. H₀: μ ≠ 250, Hₐ: μ = 250

  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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\)

  1. Random cups; \(n = 36 \ge 30\); \(\sigma\) known
  2. \(\text{SE} = 6/\sqrt{36} = 1\)
  3. \(z = (252.3 - 250)/1 = 2.30\)
Excerpt of the z-table: P(Z < z), the area to the left of z. Rows give z to one decimal; columns give the second decimal.
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
  1. Row 2.3: z to one decimal
  2. Column .00: second decimal
  3. 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.

  1. 0.0214

  2. 0.0107

  3. 0.9893

  4. 0.4893

  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. Conclude

Problem B · coffee machine

Step 5, in context.

\(p = 2(1 - 0.9893) = 0.0214\), \(\alpha = 0.05\)

  1. \(0.0214 < 0.05\): reject \(H_0\)
  2. 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.

  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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.

  1. \(H_0: \mu = 100\), \(H_a: \mu > 100\) (right tail), \(\alpha = 0.05\)
  2. Random cars; \(n = 64 \ge 30\); \(\sigma = 8\) known
  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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\)

  1. \(\text{SE} = 8/\sqrt{64} = 1\)
  2. \(z = (101.5 - 100)/1 = 1.50\)
Excerpt of the z-table: P(Z < z), the area to the left of z. Rows give z to one decimal; columns give the second decimal.
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
  1. Row 1.5: z to one decimal
  2. Column .00: second decimal
  3. P(Z < 1.50) = 0.9332
  1. Right tail: \(p = 1 - P(Z < 1.50)\)
  2. \(= 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.

  1. Fail to reject H₀: not enough evidence that the mean speed is above 100 km/h

  2. Accept H₀: the mean speed is 100 km/h

  3. There is a 6.68% chance that the mean speed is 100 km/h

  4. 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.

Excerpt of the z-table: P(Z < z), the area to the left of z. Rows give z to one decimal; columns give the second decimal.
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

  1. 0.9032

  2. 0.0968

  3. 0.1936

  4. 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.

  1. A Type II error

  2. A Type I error

  3. A correct decision

  4. 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.

1,000 drugs
100 work × power 0.80 80 pass
900 do nothing × α = 0.05 45 pass

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.

  1. Power falls

  2. Power rises: a stricter test is a better test

  3. No change: α only controls Type I errors

  4. 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).

Figure 6: The α–β trade-off in the drug trial. The solid curve shows where the sample mean x̄ lands if H₀ is true (μ = 14 days); the dashed curve shows where it lands if the drug really shortens recovery by one day (μ = 13). The test rejects when its left-tailed p-value is below . The cutoff marks where , with . A stricter α moves the cutoff left: fewer false alarms, but β grows and power falls. A larger n narrows both curves, so power rises at the same α. The shaded tails continue past both edges; the stated α, β and power include the complete off-chart tail mass.

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.

  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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.

  1. \(H_0: \mu = 9.0\), \(H_a: \mu < 9.0\), \(\alpha = 0.01\)
  2. Random calls; \(n = 100 \ge 30\); \(\sigma = 2.0\) known
  3. \(\text{SE} = 2.0/\sqrt{100} = 0.2\), \(z = (8.55 - 9.0)/0.2 = -2.25\)
  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. 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

Excerpt of the z-table: P(Z < z), the area to the left of z. Rows give z to one decimal; columns give the second decimal.
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
  1. \(P(Z < 2.25) = 0.9878\)
  2. \(p = 1 - 0.9878 = 0.0122\)
  3. \(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.

  1. ?
  2. ?
  3. ?
  4. ?
  5. ?

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.

Excerpt of the z-table: P(Z < z), the area to the left of z. Rows give z to one decimal; columns give the second decimal.
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
  1. Hypotheses
  2. Conditions
  3. Statistic
  4. p-value
  5. Conclude

Problem E · check your five lines

Compare line by line.

Loaves: \(\sigma = 15\), \(n = 81\), \(\bar{x} = 797.0\), \(\alpha = 0.05\)

  1. \(H_0: \mu = 800\), \(H_a: \mu \ne 800\), \(\alpha = 0.05\)
  2. Random loaves; \(n = 81 \ge 30\); \(\sigma\) known
  3. \(\text{SE} = 15/9 \approx 1.667\), \(z = (797.0 - 800)/1.667 = -1.80\)
  4. \(p = 2(1 - P(Z < 1.80)) = 2(1 - 0.9641) = 0.0718\)
  5. \(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.

  1. p = 0.0359, reject H₀

  2. p = 0.0718, fail to reject H₀

  3. p = 0.9641, fail to reject H₀

  4. 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.

  1. A Type I error

  2. A Type II error

  3. A correct decision

  4. 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.

  1. Confident: I could do it now

  2. Mostly: I would check one step

  3. Unsure about the table or the tail

  4. Not yet