A bakery prints “500 g” on every loaf. You weigh 36 loaves and the average is 497.6 g. Is the bakery shorting its customers, or is a 2.4 g gap just the normal wobble you’d expect from any sample? Hypothesis testing is the method statisticians use to answer exactly that kind of question.
In short, hypothesis testing is a way to decide whether data from a sample gives strong enough evidence against a default claim about a whole population. You start by assuming nothing unusual is going on, measure how surprising your data would be under that assumption, and only reject the assumption if the data is too surprising to shrug off.
This guide walks through the two hypotheses, the five steps, a full worked example with the bakery numbers, an interactive chart you can play with, and the mistakes people make when they read a p-value.
Quick Info
| Topic | Detail |
|---|---|
| Short definition | A method for deciding whether sample data provides enough evidence to reject a default claim (the null hypothesis) about a population |
| The two claims | Null hypothesis (H₀): no effect or no difference. Alternative hypothesis (H₁): the effect or difference you suspect |
| Key number | The p-value: how likely a result at least this extreme would be if H₀ were true |
| Usual decision rule | Reject H₀ if p ≤ α, where α (the significance level) is often 0.05 |
| Two possible errors | Type I (rejecting a true H₀) and Type II (missing a real effect) |
| Common mistake | Reading “fail to reject H₀” as “H₀ is proven true” |
| Reading time | About 9 minutes |
What Is Hypothesis Testing?
Hypothesis testing is a formal way of using a sample to judge a claim about a population, by asking how likely your result would be if the claim of “no effect” were true.
It belongs to inferential statistics, the branch that uses a sample to say something about a larger group. You almost never get to measure every loaf, every patient or every voter, so you measure some of them and reason from there.
A courtroom is the classic comparison. The defendant is presumed innocent (that’s the null hypothesis), and the jury only convicts if the evidence is strong enough to rule that out beyond reasonable doubt. Penn State’s statistics program uses this same analogy: the null hypothesis is always the starting assumption, and the evidence has to overturn it.
Penn State’s review of hypothesis testing lays out the same logic: state H₀ and H₁, assume H₀ is true, then decide whether the data is unlikely enough under that assumption to reject it.
Null hypothesis vs alternative hypothesis
| Null hypothesis (H₀) | Alternative hypothesis (H₁) | |
|---|---|---|
| What it says | Nothing has changed; any gap is chance | There is a real effect or difference |
| Bakery example | The true average loaf weight is 500 g | The true average is not 500 g |
| Role in the test | Assumed true until the data says otherwise | What you accept as plausible if H₀ is rejected |
| Always contains | An equals sign (=, ≤ or ≥) | A “not equal”, “greater than” or “less than” sign |
The 5 Steps of a Hypothesis Test
- State H₀ and H₁ in plain words and in symbols.
- Choose the significance level (α) before you look at the results. 0.05 is common; 0.01 is stricter.
- Calculate the test statistic, which measures how far your sample result sits from what H₀ predicts, in units of standard error.
- Find the p-value, the probability of getting a result at least this extreme if H₀ were true.
- Decide and explain: if p ≤ α, reject H₀; otherwise, fail to reject it. Then say what that means for the real question.
Choosing α first matters. If you pick it after seeing the p-value, you can talk yourself into any conclusion.
Worked Example: Is the Bakery Shorting Its Loaves?
The scenario and numbers here are illustrative. Suppose a quality checker knows from past audits that loaf weights at this bakery vary with a standard deviation of 6 g. She weighs a random sample of 36 loaves and gets an average of 497.6 g.
Step 1: State the hypotheses
H₀: μ = 500 g (the loaves weigh what the label says on average).
H₁: μ ≠ 500 g (the true average is different).
This is a two-tailed test, because a bakery that overfills is also worth knowing about.
Step 2: Choose α
She picks α = 0.05 before weighing anything.
Step 3: Calculate the test statistic
Because the population standard deviation is known and the sample is reasonably large, a z test fits:
z = (x̄ − μ₀) ÷ (σ ÷ √n)
Here x̄ is the sample mean (497.6), μ₀ is the value H₀ claims (500), σ is the standard deviation (6) and n is the sample size (36). The bottom part, σ ÷ √n = 6 ÷ 6 = 1, is the standard error.
z = (497.6 − 500) ÷ 1 = −2.40
The sample mean sits 2.4 standard errors below the label weight. If you want a refresher on what that number means, see our guide to the z-score.
Step 4: Find the p-value
For a two-tailed test, the p-value is the area in both tails of the normal distribution beyond ±2.40. Using a z table, the area below −2.40 is 0.0082, so:
p = 2 × 0.0082 = 0.0164
Step 5: Decide and explain
Because 0.0164 is less than 0.05, she rejects H₀. In plain words: if the bakery’s loaves really averaged 500 g, a sample this light would turn up only about 1.6% of the time. That’s strong evidence the true average is below 500 g.
Notice how the decision depends on α. At a stricter α = 0.01, the same data gives p = 0.0164 > 0.01, so she would fail to reject H₀. The data didn’t change; the standard of proof did.
The same answer from a confidence interval
A 95% confidence interval for the true mean is 497.6 ± 1.96 × 1, or 495.64 g to 499.56 g. Since 500 g falls outside it, the interval tells the same story as the test. You can check intervals like this with our confidence interval calculator.
Try It: When Does the Result Become Significant?
Move the slider to change the sample average and switch α. The shaded tails are the “rejection region”. When the marker lands inside a shaded tail, the p-value drops below α and the test rejects H₀.
Assumes H₀: μ = 500 g, σ = 6 g, n = 36, so the standard error is 1 g. Illustrative numbers.
Two things stand out when you play with it. The cutoff for α = 0.05 sits at 498.04 g, so a sample average of 498.0 g already counts as significant while 498.5 g doesn’t. And at α = 0.01 the cutoff moves out to 497.42 g, which is why the bakery result of 497.6 g passes one standard and fails the other.
Type I and Type II Errors
Every test can go wrong in two ways, because you are deciding with incomplete information.
| H₀ is actually true | H₀ is actually false | |
|---|---|---|
| You reject H₀ | Type I error (false alarm). Probability = α | Correct decision |
| You fail to reject H₀ | Correct decision | Type II error (missed effect). Probability = β |
For the bakery, a Type I error means accusing an honest bakery. A Type II error means letting a short-weighting bakery off the hook. Lowering α makes false alarms rarer but misses more real problems, unless you also collect a bigger sample.
The NIST/SEMATECH e-Handbook of Statistical Methods makes a related point: not rejecting the null hypothesis may simply mean you don’t yet have enough data, not that the null hypothesis is true.
One-Tailed vs Two-Tailed Tests
A two-tailed test asks “is it different?” and splits α across both tails. A one-tailed test asks “is it lower?” (or “higher?”) and puts all of α in one tail.
- Use two-tailed when a difference in either direction matters, or when you’re unsure. It’s the safer default.
- Use one-tailed only when the opposite direction truly doesn’t matter and you decided that before seeing the data. For the bakery, a consumer group only worried about underweight loaves could test H₁: μ < 500, which gives p = 0.0082.
Switching to one-tailed after seeing the data, just to halve the p-value, is one of the most common ways people fool themselves.
Myths About P-Values and Significance
| Myth | Reality |
|---|---|
| p = 0.03 means there’s a 3% chance H₀ is true | It means a result this extreme would happen about 3% of the time if H₀ were true. It is not the probability that H₀ is true. |
| “Not significant” means “no effect” | It means the data wasn’t strong enough to rule out chance. A small sample can easily miss a real effect. |
| Significant means important | With a huge sample, a 0.1 g difference can be “significant” and still not matter to anyone buying bread. |
| 0.05 is a law of nature | It’s a convention. Fields like particle physics or drug safety often use much stricter levels. |
| A good test fixes bad data | If the sample is a biased sample, the p-value is meaningless no matter how small it is. |
Frequently Asked Questions
What is a simple example of hypothesis testing?
Checking whether a coin is fair. H₀ says heads come up 50% of the time. You flip it many times, then ask how likely your count of heads would be if the coin were fair. If the result is very unlikely under H₀, you conclude the coin is probably biased.
What does it mean to reject the null hypothesis?
It means your data would be unusual enough under the null hypothesis (p ≤ α) that you no longer treat “no effect” as a reasonable explanation. It doesn’t prove the alternative with certainty; it says the evidence points that way at your chosen standard.
Why do we say “fail to reject” instead of “accept” the null?
Because a lack of evidence isn’t proof. A jury that finds someone “not guilty” hasn’t proven innocence; the case just wasn’t strong enough. In the same way, a non-significant test leaves the null hypothesis standing without confirming it.
What significance level should I use?
Many fields use 0.05 by default. Use 0.01 or stricter when a false alarm is costly, such as declaring a treatment works. Whatever you choose, set it before looking at the results and report it alongside your p-value.
Which test should I use: z or t?
Use a z test when the population standard deviation is known, or the sample is large. Use a t test when you estimate the standard deviation from a smaller sample. The logic of the five steps is the same; only the formula and table change.
Does a smaller p-value mean a bigger effect?
Not necessarily. A tiny p-value can come from a small effect measured on a very large sample. To judge the size of an effect, look at the difference itself or a confidence interval, not just the p-value.
Conclusion
Hypothesis testing turns a vague hunch (“these loaves look light”) into a clear question with a clear rule: assume nothing is wrong, measure how surprising the data is, and only change your mind when the surprise is big enough. The p-value is the measure of surprise, α is your standard of proof, and both types of error are always possible.
Next time you see “statistically significant” in a headline, ask yourself: significant compared with what α, from how large a sample, and is the difference big enough to matter?
References
- Penn State Eberly College of Science, “Hypothesis Testing” (statistical concepts review). online.stat.psu.edu
- NIST/SEMATECH, “e-Handbook of Statistical Methods: Hypothesis test” (section 7.1.3). itl.nist.gov
Disclaimer
This article is for general educational purposes only. The bakery scenario and its figures are illustrative, not data from a real business. For research design or regulatory testing, consult a qualified statistician.