Specialty Digest

Global English editionLearners’ Study Dashboard — in development
The Knowledge Library for All

Introductory Statistics / Module 5, Testing Claims with Data / Lesson 1

Hypothesis Tests for a Mean

Learn how to set up and run a hypothesis test for a mean, read a p-value correctly, and avoid common errors, with a live evidence visualiser, worked examples, graded practice and full answers.

  • Statistics
  • First-year university and advanced high school
  • About 60 minutes
  • Evidence visualiser, worked examples and practice

1Learning goal: what you will be able to do

A hypothesis test asks a yes-or-no question of data: is what we observed too unusual to blame on chance? By the end of this lesson you will be able to set up a test about a population mean, calculate a test statistic and p-value, make a decision, and explain what the decision does and does not mean.

Time55 to 60 minutes
You needPen, paper, a calculator and a normal table

Learning outcomes

  • FoundationState a null and an alternative hypothesis for a claim about a mean, and choose between a one-tailed and a two-tailed test.
  • CoreCalculate the test statistic and the p-value for a one-sample z test, and decide using the significance level α.
  • CoreUse the critical-value method, relate a test to a confidence interval, and write a conclusion in context without overstating it.
  • ExtensionPerform a one-sample t test, and explain Type I and Type II errors and multiple testing.

Where this lesson fits

This is the first lesson of Module 5 in Introductory Statistics. It is the second major use of the standard error: the previous lesson used it to estimate, and this one uses it to decide. The next lesson, on proportions, repeats the method for yes-or-no data.

  1. Module 4, Lesson 1: Sampling distributions and the Central Limit TheoremOpen
  2. Module 4, Lesson 2: Confidence intervals for a meanOpen
  3. Module 5, Lesson 1: Hypothesis tests for a meanThis lesson
  4. Module 5, Lesson 2: Inference for proportionsPlanned

Where this topic appears in courses

Hypothesis testing is core content in a first university statistics course, in AP Statistics (the units on inference), and in the IB Mathematics higher level options, and it underpins empirical work in economics, medicine, psychology, engineering and data science. Courses differ in whether they lead with the p-value or the critical-value method; both are taught here. This lesson supports, and does not replace, your own syllabus and instructor.

2A familiar example: the suspicious coin

A friend flips a coin to decide who pays for lunch and it lands heads. Fine. It lands heads again. Still fine. After the sixth head in a row, you start to wonder whether the coin is fair. Why six, and not two?

Predict first: how surprising is six heads in a row from a fair coin?

Work out the chance of six heads in a row if the coin is fair.

About 1.6%. Each flip is heads with probability 1/2, so six in a row has probability (1/2)6 = 1/64 ≈ 0.0156. That is rare, but not impossible: about one fair coin in 64 would do it. Two heads in a row (25%) would not have made you suspicious at all.

You just ran a hypothesis test in your head. You started by assuming the coin is fair (the null hypothesis). You asked how likely a result this extreme would be if that assumption were true (the p-value). When that probability was small enough, you doubted the assumption. The formal version does this carefully, with a threshold chosen in advance so that you cannot move the goalposts after seeing the data.

For means the question is: "If the population mean really were the claimed value, how unusual is the sample mean we got?" The standard error provides the yardstick. Experiment with the visualiser below.

Try it: the test visualiser

The claim is H0: μ = 100, with a known σ = 15. Move the sample mean and the sample size. The blue area is the p-value: the probability, if H0 is true, of a result at least as extreme as yours. The red areas are the rejection region, whose total area equals α. If the dashed line falls in red, the test rejects H0.

Things to notice: the same sample mean gives a more extreme z when n is larger, because the standard error is smaller. A larger sample can turn a non-significant result into a significant one without any change in the sample mean.

3Clear explanation

The two hypotheses

The null hypothesis H0 is the default claim, always stated with an equals sign: H0: μ = μ0. The alternative hypothesis Ha is what the evidence would support if the null is rejected. It has one of three forms:

Question being askedHaType of test
Is the mean different from μ0 (either way)?μ ≠ μ0Two-tailed
Is the mean larger than μ0?μ > μ0Right-tailed
Is the mean smaller than μ0?μ < μ0Left-tailed

Choose Ha from the question before looking at the data. Switching to a one-tailed test after seeing which way the sample mean fell is a form of cheating.

The test statistic

For a mean with known σ, the test statistic counts how many standard errors the sample mean is from the hypothesised mean:

z = (x̄ − μ0) / (σ/√n)

The p-value

The p-value is the probability, assuming H0 is true, of getting a test statistic at least as extreme as the one observed, in the direction of Ha.

  • Right-tailed: p = P(Z > z) = 1 − Φ(z).
  • Left-tailed: p = P(Z < z) = Φ(z).
  • Two-tailed: p = 2 × P(Z > |z|), the area in both tails.

What a p-value is not: it is not the probability that H0 is true, and it is not the probability that the result happened by chance. It is the probability of data this extreme given that H0 is true. A small p-value means the data are surprising if H0 holds.

Making the decision

Fix a significance level α before collecting data (commonly 0.05; also 0.10 or 0.01). Then:

  • If p < α: reject H0. The result is statistically significant at level α.
  • If p ≥ α: fail to reject H0. We do not "accept" H0; absence of evidence against it is not evidence for it.

Equivalent critical-value method: reject H0 if the test statistic lies in the rejection region. For α = 0.05 the critical values are ±1.96 (two-tailed), 1.645 (right-tailed) and −1.645 (left-tailed). For α = 0.01 they are ±2.576 (two-tailed) and 2.326 (one-tailed).

Writing the conclusion

State the decision, link it to the claim, and mention the level, in context. For example: "At the 5% level there is statistically significant evidence that the mean fill is different from 500 ml." Avoid "proved" and avoid treating a significant result as an important one: with a huge sample, a tiny and useless difference can be significant, so always look at the size of the effect as well.

Link with confidence intervals

A two-tailed test at level α rejects H0: μ = μ0 exactly when μ0 lies outside the (1 − α) confidence interval. The interval shows which values of the mean are plausible, which is more informative than a bare yes or no.

When σ is unknown: the t test

Replace σ with the sample standard deviation s and the normal table with the t distribution with n − 1 degrees of freedom: t = (x̄ − μ0)/(s/√n). For 15 degrees of freedom the two-tailed 5% critical value is 2.131, a little larger than 1.96.

Errors

H0 is trueH0 is false
Reject H0Type I error, probability αCorrect decision
Fail to reject H0Correct decisionType II error, probability β

The power of a test, 1 − β, is the probability of correctly rejecting a false null. Power rises with sample size, with the size of the true effect, and with α. Running many tests inflates the chance of at least one false positive, which is why unplanned searching through data for "significant" results is unreliable.

Common mistakes

MistakeWhy it is wrongFix
"The p-value is the probability H0 is true"It is computed assuming H0 is trueSay "if H0 were true, data this extreme would occur with probability p"
"We accept H0"A non-significant result is not proof of no effectSay "fail to reject"
Forgetting to double for a two-tailed testBoth tails count as extremeTwo-tailed p = 2 × the tail area
Choosing Ha after seeing the dataIt inflates the chance of a false positiveDecide H0, Ha and α first
Equating significant with importantLarge samples detect trivial differencesReport the estimate and an interval too
Using σ instead of σ/√nThat tests an individual, not a meanAlways use the standard error

4Worked examples

Read each example with a pencil in hand. Cover the steps, attempt the first line yourself, then compare. Every test follows the same five steps: hypotheses, test statistic, p-value or critical value, decision, conclusion in context.

Example 1 Foundation 3 marks: writing the hypotheses

State H0 and Ha for each situation. (a) A bakery says its loaves weigh 500 g on average, and an inspector suspects they weigh less. (b) A machine is set to cut 50 mm parts, and a technician wants to know whether it has drifted. (c) A school claims the average class test score is below 60, and a parent wants to challenge it by showing it is higher.

  1. (a) H0: μ = 500. Ha: μ < 500 (left-tailed, because the suspicion is "less").
  2. (b) H0: μ = 50. Ha: μ ≠ 50 (two-tailed, because drift could be in either direction).
  3. (c) H0: μ = 60. Ha: μ > 60 (right-tailed, because the challenge is that it is higher).

Answer: (a) left-tailed, (b) two-tailed, (c) right-tailed. The null always has the equals sign.

Example 2 Core 5 marks: a right-tailed z test

A manufacturer claims its light bulbs last 1,000 hours on average. The standard deviation is known to be 100 hours. A buyer tests 36 bulbs and finds a mean of 1,030 hours. Is there evidence at the 5% level that the mean life is greater than 1,000 hours?

  1. Hypotheses. H0: μ = 1000. Ha: μ > 1000. α = 0.05.
  2. Test statistic. SE = 100/√36 = 16.67. z = (1030 − 1000)/16.67 = 1.80.
  3. p-value. P(Z > 1.80) = 1 − 0.9641 = 0.0359.
  4. Decision. 0.0359 < 0.05, so reject H0.
  5. Conclusion. At the 5% level there is statistically significant evidence that the mean bulb life exceeds 1,000 hours.

Answer: z = 1.80, p = 0.036, reject H0. Note that at the 1% level the same data would not be significant, since 0.036 > 0.01. The level must be chosen before looking.

Example 3 Core 5 marks: a two-tailed z test

A filling machine should put 500 ml in each bottle, with a known σ of 4 ml. A random sample of 64 bottles has a mean of 499 ml. Test at the 5% level whether the mean fill differs from 500 ml.

  1. Hypotheses. H0: μ = 500. Ha: μ ≠ 500. α = 0.05.
  2. Test statistic. SE = 4/√64 = 0.5. z = (499 − 500)/0.5 = −2.00.
  3. p-value. Two-tailed: 2 × P(Z > 2.00) = 2 × 0.02275 = 0.0455.
  4. Decision. 0.0455 < 0.05, so reject H0.
  5. Conclusion. At the 5% level there is statistically significant evidence that the mean fill differs from 500 ml; it appears to be lower.

Answer: z = −2.00, p = 0.0455, reject H0 at 5% (but not at 1%).

Example 4 Core 4 marks: the critical-value method

A left-tailed test at α = 0.05 gives z = −1.20. Decide using the critical value, and find the p-value to confirm.

  1. The left-tailed 5% critical value is −1.645. Reject H0 only if z < −1.645.
  2. −1.20 is not less than −1.645, so it is outside the rejection region. Fail to reject H0.
  3. Confirm with the p-value: Φ(−1.20) = 0.1151, which is greater than 0.05. Same decision.

Answer: fail to reject H0. The two methods always agree.

Example 5 Core 4 marks: linking the test to an interval

Use the bottle data from Example 3 (x̄ = 499, SE = 0.5) to build a 95% confidence interval and check that it agrees with the test.

  1. Margin = 1.96 × 0.5 = 0.98.
  2. Interval = 499 ± 0.98 = (498.02, 499.98).
  3. The hypothesised mean 500 is outside the interval, so a two-tailed test at 5% rejects H0, as found in Example 3.
  4. The interval adds information: the true mean fill is plausibly between 498.02 and 499.98 ml, a shortfall of up to about 2 ml.

Answer: (498.02, 499.98). It excludes 500, matching the rejection. Whether a shortfall of 0 to 2 ml matters is a practical question the test cannot answer.

Example 6 Extension 5 marks: a one-sample t test

A random sample of 16 items from an approximately normal population has x̄ = 54 and s = 8. Test H0: μ = 50 against Ha: μ ≠ 50 at the 5% level.

  1. σ is unknown, so use t with 16 − 1 = 15 degrees of freedom.
  2. SE = 8/√16 = 2. t = (54 − 50)/2 = 2.00.
  3. Critical value for 15 df, two-tailed 5%: 2.131. Since |2.00| < 2.131, the statistic is not in the rejection region.
  4. The exact p-value is about 0.064, above 0.05, which agrees.
  5. Conclusion. Fail to reject H0: at the 5% level the data do not provide statistically significant evidence that the mean differs from 50.

Answer: t = 2.00, p ≈ 0.064, fail to reject H0. With z and σ = 8 known, the same statistic 2.00 would have been significant (p = 0.0455): the extra uncertainty of estimating σ matters.

Example 7 Extension 3 marks: multiple tests

A researcher runs 20 independent tests at α = 0.05, and in every case the null hypothesis is actually true. What is the chance of at least one false positive?

  1. Each test has probability 0.95 of correctly not rejecting.
  2. All 20 correct: 0.9520 = 0.3585.
  3. At least one false positive: 1 − 0.3585 = 0.6415.

Answer: about 64%. This is why a single "significant" finding among many unplanned tests deserves caution, and why analyses should be planned and reported in full.

5Learner practice

Work each question on paper first, then enter your answer. You get two tries on each question. Two questions generate new numbers every time. For probabilities, give a decimal such as 0.0455.

Question 1 · Foundation2 marks

A company claims that its mean delivery time is 3 days. A customer group believes deliveries take longer. What are the hypotheses?

Question 2 · Foundation2 marks

We test H0: μ = 50 with σ = 10. A random sample of 25 has mean 52. Find the test statistic z.

z =
Question 3 · Core · new numbers each time3 marks

z =
Question 4 · Core2 marks

A two-tailed z test gives z = 2.00. Find the p-value. Answers within 0.003 are accepted.

p =
Question 5 · Core2 marks

A test gives a p-value of 0.03. The significance level is α = 0.05. What is the correct decision and conclusion?

Question 6 · Core · new numbers each time3 marks

p =
Question 7 · Core2 marks

Which statement correctly describes a p-value of 0.02?

Question 8 · Extension3 marks

A random sample of 16 has mean 54 and sample standard deviation s = 8. Test H0: μ = 50 (σ unknown). Find the t statistic.

t =
Question 9 · Extension2 marks

What is a Type I error?

6Answer explanations

Attempt every question before you open these. A right answer with a wrong method is luck, so read each explanation even when you were correct. Questions 3 and 6 show their own worked solution as soon as you answer.

Question 1: writing the hypotheses

Answer: H0: μ = 3 and Ha: μ > 3.

The null is the claim being tested and always contains the equals sign (a is reversed). The customers suspect deliveries take longer, so the alternative is one-sided and points upward; ≠ (c) would suit a question about any difference, and < (d) points the wrong way.

Question 2: the z statistic

SE = 10/√25 = 10/5 = 2. z = (52 − 50)/2 = 1.0.

A common slip is dividing by σ = 10 instead of the standard error, which gives 0.2 and understates the evidence.

Question 3: generated z statistic

Compute the standard error σ/√n, then divide the gap (x̄ − μ0) by it. The sign matters: a sample mean below μ0 gives a negative z. Use New numbers to practise.

Question 4: two-tailed p-value

The area beyond z = 2.00 in one tail is 0.02275. A two-tailed test counts both tails: 2 × 0.02275 = 0.0455.

Forgetting to double gives 0.0228, which would be the p-value of a one-tailed test.

Question 5: decision from a p-value

Answer: reject H0; the result is statistically significant at the 5% level.

0.03 is smaller than 0.05, so the data would be unusual if H0 were true. Option (b) reverses the rule. Options (c) and (d) misread the p-value as the probability that H0 is true or false, which it is not. We also never "accept" H0; we only fail to reject it.

Question 6: generated p-value

Find the tail area beyond |z|. Double it for a two-tailed test; use it as it stands for a one-tailed test in the direction of Ha. Use New numbers to practise both kinds.

Question 7: what a p-value means

Answer: if H0 were true, data at least this extreme would occur with probability 0.02.

The p-value is a probability about the data, calculated assuming the null. It is not the probability that the null is true (a), nor that the alternative is true (b), and it says nothing about the size of the effect (d).

Question 8: the t statistic

SE = s/√n = 8/√16 = 8/4 = 2. t = (54 − 50)/2 = 2.0, with 15 degrees of freedom.

The arithmetic matches a z test, but the decision uses the t distribution, whose heavier tails make the same statistic less impressive.

Question 9: Type I error

Answer: rejecting a null hypothesis that is actually true; its probability is α.

It is a false alarm. Failing to reject a false null (a) is a Type II error. A small sample does not itself cause a Type I error (b), and an arithmetic mistake is simply a mistake (c).

7Short recap

  1. A hypothesis test asks whether sample data are too unusual to be explained by chance if the null hypothesis is true.
  2. H0 always contains the equals sign. Ha is one-tailed (< or >) or two-tailed (≠), chosen before seeing the data.
  3. Test statistic: z = (x̄ − μ0)/(σ/√n). With σ unknown, use t with n − 1 degrees of freedom.
  4. The p-value is the probability, assuming H0 is true, of a result at least as extreme as the one observed. Double the tail area for a two-tailed test.
  5. Reject H0 when p < α; otherwise fail to reject. The critical-value method gives the same decision.
  6. Failing to reject is not proof that H0 is true, and a p-value is not the probability that H0 is true.
  7. A Type I error rejects a true null (probability α). A Type II error misses a real effect.
  8. Statistical significance is not practical importance. Report an interval alongside the test, and beware many unplanned tests.

Tick what you can now do

If you ticked fewer than four, return to the matching worked example, redo it without looking, then try the generated questions again. A good next step is to read the same data through both lenses: a confidence interval and a test.

Related lessons and Encyclopedia entries

References and further reading

Titles and publishers only. Search each site for the title to reach the exact page.

  • OpenStax, Introductory Statistics 2e, the chapters on hypothesis testing with one sample. Free and open textbook. https://openstax.org/
  • Diez, D. M., Barr, C. D. and Çetinkaya-Rundel, M., OpenIntro Statistics, the chapter on inference for numerical data. https://www.openintro.org/
  • Freedman, D., Pisani, R. and Purves, R., Statistics, the chapters on tests of significance. W. W. Norton.
  • MIT OpenCourseWare, 18.05 Introduction to Probability and Statistics, notes on null hypothesis significance testing. https://ocw.mit.edu/