Privacy note: We capture your IP address to provide customised and focused services. See our Privacy Policy.

Data Science & Statistics with Python — Alpha School

Lesson 11: p-values, Errors and What Tests Cannot Tell You

The p-value is the most used and most misunderstood number in statistics. It is the probability of seeing data as extreme as yours, or more extreme, if the null hypothesis were true. It is not the probability that the null hypothesis is true. That mistake — reading a p-value of 0.03 as "there is a 3% chance the null is true" — is so common it has a name, and it is wrong in both directions: the p-value assumes the null is true and asks about the data, while the mistaken reading asks about the null given the data. Those are different questions, and only the first is what the test answers.

Tests can also be wrong in two ways. A Type I error is rejecting a null hypothesis that is actually true — a false alarm. A Type II error is failing to reject a null that is actually false — a missed signal. The significance level, usually 0.05, is the rate of Type I errors you are willing to accept: if you run many tests on data where nothing is happening, about 5% of them will cry wolf. The power of a test is its ability to avoid Type II errors — to detect a real effect when one exists — and it grows with sample size and with the size of the effect.

The Multiple Testing Trap

Testing many things at once creates a trap. If you test twenty unrelated questions at the 0.05 level, you should expect about one false alarm purely by chance, even if nothing is real. The analyst who tests everything, finds one "significant" result, and reports only that one is not discovering something — they are fishing. The honest fixes are to decide your question before looking at the data, to report all the tests you ran, and to use a stricter threshold when many tests are run, for example by dividing 0.05 by the number of tests.

There is a deeper limit too. A test can tell you whether the data is surprising under the null; it cannot tell you whether the effect is large, important, or caused by what you think caused it. A tiny difference can be statistically significant with a huge sample, and a large difference can fail to reach significance with a tiny one. Significance is a statement about the evidence, not about the size or the meaning of what was found. Always report the effect and its interval alongside the p-value.

A Worked Example

Imagine a worked example: a school tests whether a new revision app improves scores. With 30 students, the app group scores 3 points higher, p = 0.18 — not significant. With 3,000 students, the same 3-point gap gives p = 0.001 — highly significant. The effect never changed; only the sample grew. The right conclusion in both cases is the same: the app is associated with about 3 points, and the interval shows how precisely that is known. The p-value alone would have told two different stories about the same effect.

The Reproducibility Crisis in Miniature

Science has faced a real problem with results that do not reproduce: a study finds an effect, another team tries the same study, and the effect vanishes. Small p-values, flexible analyses and the habit of reporting only the significant results all contribute. Your own work can fall into the same trap on a small scale: if you try twenty analyses and report the one that worked, you have done the same thing, just without publishing it. The defences are the same ones this course teaches — decide the question first, report everything you tried, and treat a single small p-value with suspicion.

There is a hopeful side to this story. The fields that took the problem seriously now share data, share code, and pre-register their studies, and their results have become more trustworthy as a result. The habits you build in a school project — a script, a log, an honest report — are the same habits, at a smaller scale. Reproducibility is not a burden imposed on good work; it is what makes work good.

Key Terms

Type I error
Rejecting a null hypothesis that is actually true — a false alarm.
Type II error
Failing to reject a null hypothesis that is actually false — a missed signal.
Power
A test's ability to detect a real effect when one exists; it grows with sample size.
Multiple testing
Running many tests at once, which increases the chance of false alarms by chance.
Effect size
How big a difference or relationship is, as distinct from whether it is statistically significant.
p-hacking
Searching through analyses until one gives a small p-value, then reporting only that one.

Discussion Questions

  1. A p-value of 0.03 is reported. What does it mean, and what does it not mean?
  2. If you test twenty unrelated questions, why should you expect about one false alarm?
  3. A study finds a significant effect of 0.2 points on a 100-point test. Is that a success? What else do you need to know?

Practice Questions

  1. What is a p-value, in one sentence?
  2. Why is 'a p-value of 0.03 means there is a 3% chance the null is true' wrong?
  3. What is a Type I error?
  4. What is a Type II error?
  5. In the worked example, why did the same 3-point gap give p = 0.18 with 30 students and p = 0.001 with 3,000?
Show answers
  1. The probability of seeing data as extreme as yours, or more extreme, if the null hypothesis were true.
  2. Because the p-value assumes the null is true and asks about the data; it is not the probability that the null is true given the data. Those are different questions.
  3. Rejecting a null hypothesis that is actually true — a false alarm.
  4. Failing to reject a null hypothesis that is actually false — missing a real signal.
  5. Because the p-value depends on sample size as well as the effect: with more data the same gap is stronger evidence against the null. The effect never changed; only the precision did.
Keep reading to complete this lesson