Statistics & Probability · Grades 11, 12

Hypothesis Testing: Null Hypotheses, z-Tests and P-Values

Quick answer

A hypothesis test asks whether data are surprising if a claim is true. The null hypothesis states the claim, such as p = 0.5; the alternative states what we suspect instead. The test statistic z = (estimate − claimed value)/standard error measures how far the data fall from the claim. The p-value is the probability of a result at least that extreme when the null is true. A small p-value, below the significance level α, is evidence against the null.

What you'll learn

  • State null and alternative hypotheses
  • Compute a z test statistic for a proportion or a mean
  • Find and interpret a one-sided or two-sided p-value
  • Describe Type I and Type II errors

Is the data surprising if the claim is true?

A coin lands heads 6060 times in 100100 tosses. Is it unfair, or is 6060 within ordinary luck for a fair coin? A hypothesis test turns that question into arithmetic.

  1. Hypotheses. The null hypothesis H0H_0 is the claim to be tested: the coin is fair, p=0.5p = 0.5. The alternative HaH_a is what we suspect instead: p≠0.5p \ne 0.5.

  2. Test statistic. Measure how far the data fall from the claim, in standard errors, assuming H0H_0 is true:

    z=p^−p0p0(1−p0)/n=0.60−0.500.25/100=0.100.05=2z = \frac{\hat{p} - p_0}{\sqrt{p_0(1 - p_0)/n}} = \frac{0.60 - 0.50}{\sqrt{0.25/100}} = \frac{0.10}{0.05} = 2
  3. P-value. The probability of a result at least this far out, in either direction, if H0H_0 is true: 2×(1−0.9772)=0.04552 \times (1 - 0.9772) = 0.0455.

  4. Decision. At the usual significance level α=0.05\alpha = 0.05, the p-value is smaller, so we reject H0H_0: the data are evidence the coin is not fair.

The two tails beyond z = ±2 The standard normal curve from −4 to 4. The two tails beyond z = −2 and beyond z = 2 are shaded. Together they hold about 4.6 percent of the area: the two-sided p-value for 60 heads in 100 tosses. −4−224zy
  • standard normal curve
The two tails beyond z = ±2

Why we argue from the null hypothesis

We cannot compute probabilities under “the coin is unfair”, because that does not say how unfair. The null hypothesis is specific, so it fixes a sampling distribution: under p=0.5p = 0.5, p^\hat{p} is approximately normal with mean 0.50.5 and standard error 0.050.05. Against that yardstick we can say exactly how rare the data are.

The logic is like a proof by contradiction, with probability in place of certainty. If the claim leads us to expect results like ours only rarely, the claim is in doubt. A large p-value does not prove H0H_0; it only says the data are consistent with it. So we “fail to reject” rather than “accept”.

One side or two

Choose the alternative before looking at the data.

  • Two-sided, Ha:p≠p0H_a: p \ne p_0: count both tails, as with the coin.
  • One-sided, Ha:p>p0H_a: p > p_0 or Ha:p<p0H_a: p < p_0: count only the tail in the suspected direction.

For the coin, a one-sided test of p>0.5p > 0.5 would give 1−0.9772=0.02281 - 0.9772 = 0.0228.

Worked examples

Two ways to be wrong

H0H_0 is trueH0H_0 is false
reject H0H_0Type I errorcorrect
fail to reject H0H_0correctType II error

The probability of a Type I error is α\alpha itself: a true null is rejected whenever chance alone produces a p-value below α\alpha. Lowering α\alpha makes Type I errors rarer but Type II errors more common. A larger sample reduces Type II errors without raising α\alpha.

Common mistakes

Practice problems

  1. A coin lands heads 5858 times in 100100. Test H0:p=0.5H_0: p = 0.5 against Ha:p≠0.5H_a: p \ne 0.5 at α=0.05\alpha = 0.05.

    Answer

    z=1.6z = 1.6, p-value ≈0.110\approx 0.110; fail to reject.

    Full solution

    z=0.58−0.50.05=1.6z = \tfrac{0.58 - 0.5}{0.05} = 1.6. The two-sided p-value is 2(1−0.9452)=0.10962(1 - 0.9452) = 0.1096, above 0.050.05.

  2. A store claims 30%30\% of customers use its app. In a sample of 500500, 175175 do. Test Ha:p>0.3H_a: p > 0.3 at α=0.05\alpha = 0.05.

    Answer

    z≈2.44z \approx 2.44, p-value ≈0.007\approx 0.007; reject H0H_0.

    Full solution

    p^=0.35\hat{p} = 0.35. The standard error is 0.3×0.7500≈0.0205\sqrt{\tfrac{0.3 \times 0.7}{500}} \approx 0.0205, so z≈2.44z \approx 2.44 and the one-sided p-value is about 0.00730.0073.

  3. A process should average 5050 with σ=6\sigma = 6. A sample of 6464 averages 48.548.5. Test Ha:μ<50H_a: \mu < 50 at α=0.05\alpha = 0.05.

    Answer

    z=−2z = -2, p-value =0.0228= 0.0228; reject H0H_0.

    Full solution

    The standard error is 68=0.75\tfrac{6}{8} = 0.75, so z=48.5−500.75=−2z = \tfrac{48.5 - 50}{0.75} = -2, and Φ(−2)=0.0228\Phi(-2) = 0.0228.

  4. For the coin in the lesson, what is the p-value of the one-sided test Ha:p>0.5H_a: p > 0.5?

    Answer

    0.02280.0228

    Full solution

    Only the upper tail counts: 1−Φ(2)=0.02281 - \Phi(2) = 0.0228.

  5. A drug trial rejects H0H_0 (no effect) when the drug in fact has no effect. Which error is this?

    Answer

    A Type I error

    Full solution

    A true null hypothesis was rejected.

  6. A test at α=0.05\alpha = 0.05 gives a p-value of 0.080.08. What is the decision, and what does it mean?

    Answer

    Fail to reject H0H_0; the evidence against it is not strong enough at this level.

    Full solution

    Since 0.08>0.050.08 > 0.05, results like these would be fairly common if H0H_0 were true. That does not prove H0H_0.

  7. How does lowering α\alpha from 0.050.05 to 0.010.01 affect the two error types?

    Answer

    Type I errors become rarer; Type II errors become more common.

    Full solution

    A smaller α\alpha demands stronger evidence before rejecting, so true nulls are rejected less often, and false nulls are missed more often.

  8. A student says, “The p-value is 0.04550.0455, so there is a 4.55%4.55\% chance the coin is fair.” Correct the statement.

    Answer

    If the coin were fair, there would be a 4.55%4.55\% chance of a result at least this far from 5050 heads.

    Full solution

    The p-value is computed assuming H0H_0. It measures how surprising the data are under the claim, not how likely the claim is.

Frequently asked questions

What is a null hypothesis?

The claim being tested, usually a statement of no effect or no difference, such as p = 0.5 for a fair coin. The test looks for evidence against it.

What is a p-value?

The probability, assuming the null hypothesis is true, of getting a result at least as extreme as the one observed. A small p-value means the data would be surprising if the null were true.

How do you decide whether to reject the null hypothesis?

Compare the p-value with the significance level α, often 0.05. If p < α, reject the null; otherwise, fail to reject it.

What is the difference between one-sided and two-sided tests?

A one-sided test looks for a difference in one direction only, such as p > 0.3. A two-sided test looks in both directions, so its p-value counts both tails.

What are Type I and Type II errors?

A Type I error rejects a true null hypothesis; its probability is α. A Type II error fails to reject a false null hypothesis.

What to learn next

Standards alignment

This lesson covers the following Common Core State Standards for Mathematics.

  • CCSS.MATH.CONTENT.HSS.IC.A.2Making Inferences and Justifying ConclusionsDecide if a specified model is consistent with results from a given data-generating process, e.g., using simulation.
  • CCSS.MATH.CONTENT.HSS.IC.B.5Making Inferences and Justifying ConclusionsUse data from a randomized experiment to compare two treatments; use simulations to decide if differences between parameters are significant.