Find a course

Module 4: Statistical InferenceLesson 10 of 1216 min

Hypothesis Tests and P-Values

Set up null and alternative hypotheses, compute a test statistic and p-value, interpret p-values correctly and weigh Type I and Type II errors.

Step 1 of 14Learn

Innocent until proven guilty

A website's sign-up button gets clicked by 20% of visitors. The design team builds a new version and shows it to 1,000 visitors, and 23.6% click. Is the new design better, or could a jump like that happen by chance with the old click rate?

A hypothesis test answers that kind of question, and its logic works like a criminal trial.

  • The defendant is presumed innocent. In a test, we assume the null hypothesis H₀: nothing has changed, no effect, no difference. Here, H₀: p = 0.20.
  • The prosecution has a claim to prove. That's the alternative hypothesis Hₐ: here, Hₐ: p > 0.20 (the new design does better).
  • The jury asks: if the defendant were innocent, how surprising would this evidence be? We ask: if H₀ were true, how likely is a result at least as extreme as ours? That probability is the p-value.
  • If the evidence would be very surprising under innocence, the jury convicts. If the p-value is small, we reject H₀.
  • If the evidence isn't convincing, the verdict is "not guilty," which isn't the same as "innocent." We fail to reject H₀; we never "accept" or "prove" it.

Hypotheses are always statements about parameters (p, μ), never about sample statistics. We already know p̂ = 0.236; the question is what it tells us about p.

Step 2 of 14Learn

The steps of a test

Every hypothesis test follows the same steps.

  1. State hypotheses. H₀ sets the parameter equal to a specific value. Hₐ says it's greater (>), less (<), or different (≠). Use ≠ (a two-sided test) unless you had a reason, before seeing the data, to look in only one direction.
  2. Choose a significance level α. This is your threshold for "surprising enough." The most common choice is α = 0.05; 0.01 is used when false alarms are costly.
  3. Check conditions. Random sampling or assignment, and large enough samples, as for confidence intervals.
  4. Compute the test statistic. It measures how far the statistic is from the null value, in standard errors:

test statistic = (statistic − null value) / standard error

For a proportion, z = (p̂ − p₀) / √( p₀(1 − p₀) / n ). Notice the standard error uses the null value p₀, because we're assuming H₀ is true.

  1. Find the p-value: the probability, assuming H₀, of a test statistic at least as extreme as the one observed.
  2. Conclude in context. If p-value ≤ α, reject H₀: there is convincing evidence for Hₐ. If p-value > α, fail to reject H₀: there is not convincing evidence for Hₐ.

The conclusion should always be written about the real situation, not just "reject H₀."

Step 3 of 14Practice · Diagram

The five steps of every hypothesis test

At which step do you decide between > and ≠ in the alternative?

Tap the shape that answers the question, then press Check.

The five steps of every hypothesis testProcess diagram: State H₀ and Hₐ → Check conditions → Test statistic → P-value → Conclude in context.State H₀ and HₐCheck conditionsTest statisticP-valueConclude in context
State H₀ and Hₐ

Pick α and the direction of Hₐ before looking at the data.

Check conditions

Random data, independence, a large enough sample for the normal model.

Test statistic

(statistic − null value) / standard error.

P-value

Chance of results at least this extreme if H₀ were true.

Conclude in context

p ≤ α: reject H₀. Otherwise fail to reject. Say what it means for the real question.

Step 4 of 14Practice · Choose one

A cereal company claims its boxes contain 500 g on average. A consumer group suspects the boxes are underfilled. Which hypotheses should it test?

Step 5 of 14Learn

Worked example: did the new design help?

Hypotheses. H₀: p = 0.20; Hₐ: p > 0.20, where p is the proportion of all visitors who would click the new button. α = 0.05.

Conditions. Visitors were randomly shown the new design. Expected clicks under H₀: 1,000 × 0.20 = 200 and 800 non-clicks, both well above 10.

Test statistic.

  • Standard error under H₀: √(0.20 × 0.80 / 1000) = √0.00016 ≈ 0.01265
  • z = (0.236 − 0.20) / 0.01265 ≈ 2.85

The sample proportion is 2.85 standard errors above what H₀ predicts.

P-value. The area under the standard normal curve to the right of z = 2.85 is about 0.002. If the new design truly had a 20% click rate, only about 2 in 1,000 samples of this size would show a rate of 23.6% or higher.

Conclusion. Since 0.002 < 0.05, we reject H₀. There is convincing evidence that the new design's true click rate is higher than 20%.

Notice what the conclusion doesn't say. It doesn't say the click rate is exactly 23.6% (a confidence interval would estimate that), and it doesn't say the improvement is big enough to matter for the business. It only says chance alone is a poor explanation.

Step 6 of 14Try the calculator

One-proportion z test

Enter the null value, the sample size and the observed sample proportion. P-values use a close approximation to the normal curve.

Standard error under H₀
0.0126
Test statistic z
2.85
P-value for Hₐ: p > p₀
0.0021
P-value for Hₐ: p ≠ p₀
0.0042

Step 7 of 14Practice · Work it out

A test of H₀: p = 0.5 uses a random sample of n = 400 and finds p̂ = 0.56. What is the z test statistic?

Step 8 of 14Learn

Reading p-values correctly

The p-value is the most misunderstood number in science. In 2016, the American Statistical Association published a rare formal statement to clear up the confusion. The key points:

What a p-value is: the probability of getting data at least as extreme as yours, if the null hypothesis were true. A small p-value means the data are hard to explain by chance under H₀.

What a p-value is not:

  • It is not the probability that H₀ is true. A p-value of 0.03 doesn't mean a 3% chance there's no effect.
  • It is not the probability that the result happened "by chance."
  • It does not measure the size or importance of an effect. A tiny, useless effect can have a tiny p-value if the sample is huge.
  • A large p-value does not prove H₀. It means the data are consistent with H₀, and possibly with many other values too, especially in small samples.

About α = 0.05. It's a convention, not a law of nature. A p-value of 0.049 and one of 0.051 represent nearly identical evidence. Good practice reports the actual p-value and a confidence interval, not just "significant" or "not significant."

As a rough guide to the strength of evidence against H₀: p > 0.10 is weak or none, around 0.05 is moderate, below 0.01 is strong. The context, study design and effect size matter as much as the number.

Step 9 of 14Practice · Select all that apply

A study reports p = 0.03 for a test of whether a tutoring program raises test scores (α = 0.05). Which statements are correct? Select all that apply.

Select all that apply.

Step 10 of 14Learn

Type I and Type II errors

A test decision can be wrong in two ways.

  • A Type I error is rejecting H₀ when it's actually true: a false positive. The trial convicts an innocent person; a test says a useless drug works.
  • A Type II error is failing to reject H₀ when it's actually false: a false negative. A guilty person goes free; a test misses a drug that really works.

The probability of a Type I error equals α. If you test at α = 0.05 and H₀ is true, you'll wrongly reject it 5% of the time. That's the risk you agree to when you choose α.

The probability of a Type II error is called β, and power = 1 − β is the probability of correctly detecting a real effect. Power increases when:

  • the sample size is larger,
  • the true effect is bigger,
  • the data are less variable,
  • α is larger (but that raises the Type I error risk).

There's a trade-off: lowering α to avoid false positives makes false negatives more likely, for a fixed sample size. The way to reduce both is to collect more data.

Which error is worse depends on the stakes. For a screening test for a serious disease, a Type II error (missing the disease) may be worse. For approving a drug with side effects, a Type I error (approving a useless drug) may be worse.

Step 11 of 14Compare

The four possible outcomes of a test

AspectH₀ is actually trueH₀ is actually false
Reject H₀Type I error (false positive), probability αCorrect decision, probability = power
Fail to reject H₀Correct decision, probability 1 − αType II error (false negative), probability β

Step 12 of 14Practice · What would you do?

What would you do?

A regulator tests H₀: a new drug is no better than the current one, against Hₐ: the new drug is better. Which describes a Type I error in this context?

Step 13 of 14Note

Step 14 of 14Practice · True or false

A hypothesis test gives a p-value of 0.20. This proves that the null hypothesis is true.