A type 1 error is a false positive: you conclude that an effect exists, but it does not. A type 2 error is a false negative: you conclude that there is no effect, but there is one. Type 1 is a false alarm, and type 2 is a miss.
What is the difference between a type 1 and a type 2 error?
A hypothesis test starts with a default claim called the null hypothesis, for example "the new menu does not change daily sales". The data can then push you to reject that claim or not. Because data is random, you can be wrong in two ways.
| The effect is not real | The effect is real | |
|---|---|---|
| You say "there is an effect" | Type 1 error (false alarm) | Correct |
| You say "no evidence of an effect" | Correct | Type 2 error (miss) |
A smoke alarm is a good picture. A type 1 error is the alarm ringing while you toast bread. A type 2 error is a fire with a silent alarm.
| Error | Also called | Probability | Name of that probability |
|---|---|---|---|
| Type 1 | False positive | α (alpha) | Significance level, often 0.05 |
| Type 2 | False negative | β (beta) | 1 − β is the power of the test |
How often do type 1 errors happen?
You choose the rate yourself. If you reject when the p-value is below 0.05, you accept a 5% chance of a false alarm when there is truly no effect. We can check this with a simulation. Imagine Ada compares daily sales before and after a menu change. In the simulation, both groups have the same true average of 100 sales a day, so any "difference" is luck.
import numpy as np from scipy import stats rng = np.random.default_rng(42) def share_significant(true_difference, n=30, trials=5000): hits = 0 for _ in range(trials): old = rng.normal(100, 10, n) new = rng.normal(100 + true_difference, 10, n) if stats.ttest_ind(new, old).pvalue < 0.05: hits += 1 return hits / trials false_alarm_rate = share_significant(0) print(false_alarm_rate)
0.0466
In 5,000 tests with no real effect, about 4.7% came out "significant". That matches α = 0.05. These are all type 1 errors, and they are the price of using a 0.05 threshold. Lowering α to 0.01 gives fewer false alarms.
How often do type 2 errors happen?
Now give the new menu a real effect: 5 more sales a day on average, with the same spread.
power_30 = share_significant(5) power_100 = share_significant(5, n=100) print(power_30, power_100) print(round(1 - power_30, 3), round(1 - power_100, 3))
0.479 0.945 0.521 0.055
With 30 days per group, the test finds the real effect only 47.9% of the time. The other 52.1% are type 2 errors: a real improvement that the test misses. With 100 days per group, the power rises to 94.5%, and misses drop to 5.5%.
The size of the effect matters too. Try a smaller real difference of 2 sales a day:
print(share_significant(2), share_significant(2, n=100))0.111 0.2968
A small effect is hard to see, even with 100 days per group. This is why "not significant" does not mean "no effect".
Which error is worse?
It depends on the cost.
| Situation | Type 1 costs | Type 2 costs |
|---|---|---|
| Testing a new medicine | A useless drug is approved | A working drug is dropped |
| Spam filter | A real email goes to spam | A spam email arrives |
| Cafe menu test | Ada changes the menu for nothing | Ada keeps a menu that would have helped |
When a type 1 error is very costly, use a smaller α. When a miss is costly, collect more data to raise the power. You cannot reduce both errors at once without more data: for a fixed sample size, a smaller α raises β.
How do you reduce both errors?
- Collect more data. This is the only way to cut both errors together.
- Reduce noise. Measure carefully so the spread is smaller.
- Plan the sample size before the test. Decide the smallest effect you care about, then pick n.
- Do not test many things and report only the winner. Every extra test is another chance for a type 1 error.
What to read next
The lesson [Error types, power and effect size](/learn/statistics-data-analysis/error-types-power-effect-size) lets you run this kind of simulation on your own. First, make sure you know what the threshold means in [what is a p-value](/blog/what-is-a-p-value), or see how a test is used in [A/B testing explained](/blog/ab-testing-explained). The [Statistics and Data Analysis course](/courses/statistics-data-analysis) has 44 lessons and is free.
- #statistics
- #type 1 error
- #type 2 error
- #hypothesis testing