Menu
Sign up Sign in

AI HL · 13.4

Hypothesis Testing

13.4.10

Testing a mean: z-test or t-test

13.4.10

Testing a mean: z-test or t-test

Target: I can write H0 and H1 for a mean, define \(\mu\), and choose a one-tailed or two-tailed test from the wording. (+4 more)

By the end of this section

Key points

z or t?

  • Use a z-test when the population standard deviation \(\sigma\) is known. Use a t-test when it is estimated from the sample (the sample standard deviation s).
  • Both tests need the population to be normally distributed. The question will say so, or tell you to assume it.
  • A known \(\sigma\) is often signalled by 'known', 'from past records' or 'the population standard deviation'. A standard deviation worked out from the sample is a t-test.
  • If a variance is given, take the square root first. Decide whether it is the population variance (z) or the sample variance (t).

Hypotheses and tails

  • \(H_0: \mu = \mu_0\). Say in words what \(\mu\) is, for example 'the mean mass of a loaf, in grams'.
  • 'Changed' or 'different' gives \(H_1: \mu \neq \mu_0\), a two-tailed test. 'Increased' or 'more than' gives \(>\). 'Decreased' or 'less than' gives \(<\). Both of these are one-tailed.
  • The p-value is the probability, if \(H_0\) is true, of a sample mean at least as far from \(\mu_0\) as the one found, in the direction H1 states. For a two-tailed test the calculator counts both tails.

Concluding

  • Compare p with the significance level \(\alpha\). Reject \(H_0\) if \(p < \alpha\). Otherwise do not reject \(H_0\).
  • Write the conclusion in context: 'There is sufficient evidence, at the 5% significance level, that the mean … has changed.' If you do not reject \(H_0\), say 'insufficient evidence'.
  • The same p-value can give two different conclusions at two significance levels. p = 0.026 rejects \(H_0\) at 5% but not at 1%.
  • Not rejecting \(H_0\) does not prove that \(\mu = \mu_0\). The sample may simply not have shown a difference.

On the calculator

z-test from summary statistics

  • Choose the z-test, then enter \(\mu_0\), \(\sigma\), \(\bar{x}\) and n.
  • Choose the tail that matches H1: not equal, less than or greater than.
  • Read z and the p-value.

Screenshot and video to come

z-test from a data list

  • Enter the data in a list and choose the z-test with data.
  • Type in the known \(\sigma\) and \(\mu_0\). Choose the tail.
  • Read \(\bar{x}\), z and the p-value.

Screenshot and video to come

t-test from summary statistics

  • Choose the t-test, then enter \(\mu_0\), \(\bar{x}\), the sample standard deviation s and n.
  • If you are given a variance, take its square root to get s.
  • Read t, df and the p-value.

Screenshot and video to come

t-test from a data list

  • Enter the data in a list and choose the t-test with data.
  • Type in \(\mu_0\) and choose the tail.
  • Read \(\bar{x}\), s, t, df and the p-value.

Screenshot and video to come

Explore: the p-value and the critical region

The p-value is an area under the curve of the test statistic, if H₀ is true. Choose the test and H₁, then drag the orange point to the value of the statistic. The gold area is α, over the critical region.

Significance level, α
Critical value
p-value

Drag the point with the mouse or a finger, or select it (Tab) and use the arrow keys. Type a value for an exact one.

Drag the point to choose the test statistic.

  1. Drag the statistic further from the middle. What happens to the p-value? Why is a statistic far out strong evidence against H₀?
  2. Press "Move to the critical value". What is the p-value? Compare it with α.
  3. Change H₁ from > to ≠ and keep the statistic. Why does the p-value double? Where is the other half of the area?
  4. In t, make the degrees of freedom large. Which curve does the t curve become? Compare the critical values of t and z.

Worked examples

Problems like the ones in class. Pick one, try it, then open the working.
A z-test from summary data

A bakery makes loaves with a mean mass of 800 g. The masses are normally distributed with a known standard deviation of 12 g. After a new oven is fitted, the manager thinks the mean mass has changed. A random sample of 24 loaves has a mean mass of 795 g. (a) State the hypotheses and say which test you will use. (b) Test, at the 5% significance level, whether the mean mass has changed.

Working
  1. Hypotheses

    \(H_0: \mu = 800\), \(H_1: \mu \neq 800\), where \(\mu\) is the mean mass of a loaf.

    The manager thinks the mean has changed, in either direction, so H1 uses ≠ and the test is two-tailed.

  2. Choose the test

    The standard deviation 12 g is known, so use a z-test.

    Known population standard deviation: z. Estimated from a sample: t. Both need a normal population, which the question gives.

  3. Calculator

    From the calculator: \(\mu_0 = 800\), \(\sigma = 12\), \(\bar{x} = 795\), \(n = 24\), two-tailed: z = −2.04, p = 0.0412

    The calculator gives the p-value for both tails.

  4. Conclude

    0.0412 < 0.05, so reject \(H_0\). There is sufficient evidence, at the 5% significance level, that the mean mass of a loaf has changed.

    Compare p with 0.05, then answer in the words of the question.

Video walkthrough coming
A t-test from summary data

A phone maker says its batteries last 45 hours on average. After a software update, a random sample of 12 phones has a mean battery life of 43.1 hours with a sample standard deviation of 2.9 hours. Battery life is normally distributed. Test, at the 5% significance level, whether the update has reduced the mean battery life.

Working
  1. Hypotheses

    \(H_0: \mu = 45\), \(H_1: \mu < 45\), where \(\mu\) is the mean battery life after the update.

    The question asks about a reduction, so the test is one-tailed with H1 using <.

  2. Choose the test

    2.9 hours comes from the sample, so use a t-test with df = 12 − 1 = 11.

    A standard deviation from a sample is an estimate. That is the signal for a t-test.

  3. Calculator

    From the calculator: \(\bar{x} = 43.1\), \(s = 2.9\), \(n = 12\), lower tail: t = −2.27, df = 11, p = 0.0222

    Choose the lower tail to match H1.

  4. Conclude

    0.0222 < 0.05, so reject \(H_0\). There is sufficient evidence, at the 5% significance level, that the update has reduced the mean battery life.

    The p-value is below 0.05, so the result is unlikely if the mean is still 45 hours.

Video walkthrough coming
A z-test from data

A machine fills bags of flour. The masses are normally distributed with a known standard deviation of 3.5 g. The machine is meant to fill bags to a mean of 50 g. The manager suspects it overfills. The masses, in grams, of 8 bags are 52.4, 48.9, 53.6, 51.2, 54.8, 50.3, 52.9, 55.1 Test, at the 5% significance level, whether the mean mass is more than 50 g.

Working
  1. Hypotheses

    \(H_0: \mu = 50\), \(H_1: \mu > 50\), where \(\mu\) is the mean mass of a bag, in grams.

    Overfilling means a mean above 50 g, so H1 uses > and the test is one-tailed.

  2. Choose the test

    The population standard deviation 3.5 g is known, so use a z-test.

    The sample has its own standard deviation (2.17 g) but the test uses the known 3.5 g.

  3. Calculator

    Enter the data in a list. From the calculator, with \(\sigma = 3.5\): \(\bar{x} = 52.4\), z = 1.94, p = 0.0262

    The calculator finds the sample mean from the list. Choose the upper tail.

  4. Conclude

    0.0262 < 0.05, so reject \(H_0\). There is sufficient evidence, at the 5% significance level, that the machine fills the bags with a mean mass of more than 50 g.

    Answer in context.

Video walkthrough coming
A t-test from data

A seed company says its plants reach a mean height of 14.5 cm after three weeks. A gardener measures 9 plants. The heights, in centimetres, are 14.2, 15.8, 13.9, 16.4, 15.1, 14.7, 16.0, 15.5, 13.6 Heights are normally distributed. Test, at the 5% significance level, whether the mean height is different from 14.5 cm.

Working
  1. Hypotheses

    \(H_0: \mu = 14.5\), \(H_1: \mu \neq 14.5\), where \(\mu\) is the mean height after three weeks, in centimetres.

    'Different from' allows either direction, so the test is two-tailed.

  2. Choose the test

    No population standard deviation is given, so it must be estimated from the sample: a t-test with df = 9 − 1 = 8.

    With raw data and no known σ, the t-test is the one to use.

  3. Calculator

    Enter the data in a list. From the calculator: \(\bar{x} = 15.0\), \(s = 0.985\), t = 1.59, df = 8, p = 0.150

    Read the mean and standard deviation from the list as well as the p-value.

  4. Conclude

    0.150 > 0.05, so do not reject \(H_0\). There is insufficient evidence, at the 5% significance level, that the mean height is different from 14.5 cm.

    A p-value this large means the data are consistent with a mean of 14.5 cm.

Video walkthrough coming
Choosing z or t

Say whether each test needs a z-test or a t-test, and write down H0 and H1. (i) A mill's records over many years show that its sacks have a standard deviation of 0.8 kg. A sample of 10 sacks has a mean of 25.4 kg. Has the mean mass of a sack changed from 25 kg? (ii) A sample of 14 pupils has a mean reaction time of 0.31 s and a sample standard deviation of 0.05 s. Is the mean reaction time of pupils more than 0.30 s? (iii) The variance of the lifetimes of a type of bulb is known to be 64 hours². A sample of 30 bulbs has a mean of 1210 hours. Is the mean lifetime less than 1220 hours?

Working
  1. (i) Known σ

    z-test. \(H_0: \mu = 25\), \(H_1: \mu \neq 25\).

    Many years of records give the population standard deviation, so it is known. 'Changed' means two-tailed.

  2. (ii) Sample s

    t-test. \(H_0: \mu = 0.30\), \(H_1: \mu > 0.30\).

    0.05 s is a sample standard deviation, an estimate. 'More than' means H1 uses >.

  3. (iii) Known variance

    z-test with \(\sigma = \sqrt{64} = 8\). \(H_0: \mu = 1220\), \(H_1: \mu < 1220\).

    A variance for the whole type of bulb is a population value. Take its square root to get σ.

  4. Count

    z-tests: (i) and (iii). That is 2.

    Ask one question each time: is the standard deviation from the population, or from the sample?

Video walkthrough coming