A p-value is the probability of getting a result at least as extreme as yours, assuming the null hypothesis is true. A small p-value means your data does not fit well with the null hypothesis. It does not tell you the probability that the hypothesis is true, and it does not tell you how big the effect is.
What is a p-value, in plain words?
Imagine a world where nothing special is happening: the coin is fair, the new design makes no difference. That world is the null hypothesis. The p-value asks: "If that world were real, how often would I see data at least this unusual?" If the answer is "almost never", you start to doubt that world.
Example: is this coin fair?
Alex says a coin lands on heads more often than it should. Maya flips it 100 times and gets 60 heads. Is the coin unfair, or is this luck?
- Null hypothesis (H₀): the coin is fair, so the chance of heads is 0.5.
- Alternative hypothesis (H₁): the coin is not fair, so the chance is not 0.5.
If the coin were fair, how likely is a result at least as far from 50 as this one (60 or more heads, or 40 or fewer)? You can answer it with a test, and also by simulation: flip a fair coin 100 times, repeat 100,000 times, and count how often the result is that far from 50.
import numpy as np from scipy import stats result = stats.binomtest(60, n=100, p=0.5) print(round(result.pvalue, 3)) rng = np.random.default_rng(42) heads = rng.binomial(100, 0.5, size=100_000) print(round((np.abs(heads - 50) >= 10).mean(), 3))
0.057 0.057
The test and the simulation agree: p ≈ 0.057. A fair coin gives a result this far from 50 in about 6 of every 100 experiments. That is uncommon, but not shocking.
What does p = 0.05 mean?
Before the test you choose a threshold called the significance level (α). The usual choice is 0.05. It is the risk you accept of rejecting a true null hypothesis by mistake.
- If p < α, the result is called "statistically significant" and you reject H₀.
- If p ≥ α, you do not reject H₀.
So p = 0.05 is a common cutoff, not a law of nature. Here 0.057 is above 0.05, so you do not reject H₀. This does not prove the coin is fair. It says 100 flips are not enough evidence against it. With more data the story changes: 600 heads in 1,000 flips gives a p-value of about 2.7e-10, which is 0.00000000027.
p-value vs significance level: what is the difference?
The p-value comes from your data. The significance level is a rule you set before you look at the data. You compare them to make a decision. Choosing α after seeing the p-value defeats the purpose.
One-sided or two-sided?
The test above is two-sided: too many heads and too many tails both count as "extreme". If Alex had claimed from the start that the coin favors heads, a one-sided test is possible. The second output below is the 1,000-flip case from the previous section.
one = stats.binomtest(60, n=100, p=0.5, alternative="greater") print(round(one.pvalue, 3)) big = stats.binomtest(600, n=1000, p=0.5) print(f"{big.pvalue:.1e}")
0.028 2.7e-10
Same data, different question, different p-value. Choose the direction before you see the data. Switching to one-sided after the result is a way to cheat. If you are unsure, use two-sided.
Four common misreadings of the p-value
1. "p = 0.057 means a 5.7% chance that H₀ is true."
Wrong. The p-value is calculated by assuming H₀ is true. It cannot give the probability that H₀ is true. "A 5.7% chance the result is due to luck" is the same mistake.
2. "p > 0.05 means there is no difference."
Wrong. It means the evidence is too weak. Not finding a difference is not proof of no difference.
3. "A tiny p-value means a big effect."
Wrong. With very large samples, even a trivial difference gets a tiny p-value. Report the size of the difference as well, ideally with a [confidence interval](/blog/confidence-interval-explained).
4. "p = 0.049 is significant and p = 0.051 is not, so they are very different."
Wrong. They are almost the same level of evidence. Report the p-value itself, not only "significant" or "not significant".
How do you write the result correctly?
This sentence states what the p-value says and what it does not.
Steps of a hypothesis test
1. Write H₀ and H₁.
2. Choose α and the direction before looking at the data.
3. Pick the test and compute the test statistic.
4. Find the p-value.
5. Compare p with α and describe the result together with the effect size.
Common mistakes
- Choosing the threshold after seeing the result. Fix α first.
- Running tests until one is significant. With 20 independent tests and no real effect, the chance that at least one looks significant by luck is about 64%.
- Mixing up statistical and practical importance. A significant difference can still be too small to matter.
print(round(1 - 0.95 ** 20, 2))
0.64
What to read next
The lessons [Testing a claim](/learn/statistics-data-analysis/testing-a-claim) and [The p-value and the decision](/learn/statistics-data-analysis/p-value-and-decision) build this test step by step on Bazaar data. To see p-values in a real experiment, read [A/B testing explained](/blog/ab-testing-explained). The full set of 44 lessons is on the [Statistics and Data Analysis page](/courses/statistics-data-analysis).
- #statistics
- #p-value
- #hypothesis testing
- #significance