Type I and Type II Errors › Type II Errors: The Missed Discovery
Machine Learning from ScratchAll chapters Type I and Type II Errors › Type II Errors: The Missed DiscoveryOne section · Sections in this chapter4 / 10 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
A Type II error occurs when you fail to reject a false null hypothesis. In plain language: a real effect exists, but your test fails to detect it. You've missed a discovery.
The Probability of Type II Error: β
The probability of a Type II error is denoted by the Greek letter beta (β):
This is also a conditional probability: the probability of not rejecting the null hypothesis, given that it is false.
Computing β: The Mathematics
Unlike α, which you simply choose, β must be calculated based on several factors. The calculation requires specifying an alternative hypothesis: you need to know what the true state of the world is to compute the probability of missing it.
Let's work through the mathematics for a one-sample z-test. Suppose:
- Null hypothesis:
- True population mean: (where )
- Known population standard deviation:
- Sample size:
- Significance level: (two-tailed test)
Step 1: Find the critical values under
Under the null hypothesis, the test statistic follows a standard normal distribution. The critical values for a two-tailed test at significance level α are:
For α = 0.05:
Step 2: Convert critical z-values to critical sample means
We reject if falls outside the interval:
Step 3: Calculate β under the alternative
A Type II error occurs when falls in the "fail to reject" region even though the true mean is . Under the alternative:
The probability of not rejecting is:
Standardizing using the true mean :
where is the standard normal CDF.
Worked Example: Calculating β
Let's calculate β for a concrete scenario.
Scenario: A coffee company claims their beans have a mean caffeine content of 100 mg per cup (). A consumer group suspects the true content is 105 mg (). They plan to test 25 cups, and caffeine content is known to have σ = 15 mg.
import numpy as np
from scipy import stats
# Parameters
mu_0 = 100 # Null hypothesis mean
mu_1 = 105 # True mean (alternative)
sigma = 15 # Population standard deviation
n = 25 # Sample size
alpha = 0.05 # Significance level
# Standard error
se = sigma / np.sqrt(n)
print(f"Standard error: σ/√n = {sigma}/√{n} = {se:.2f}")
# Critical values for the sample mean (two-tailed test)
z_crit = stats.norm.ppf(1 - alpha / 2)
x_lower = mu_0 - z_crit * se
x_upper = mu_0 + z_crit * se
print(f"\nCritical z-value: ±{z_crit:.3f}")
print(f"Fail to reject H₀ if: {x_lower:.2f} < X̄ < {x_upper:.2f}")
# Calculate β: P(fail to reject | H₁ is true)
# This is P(x_lower < X̄ < x_upper) when X̄ ~ N(mu_1, se²)
beta = stats.norm.cdf(x_upper, loc=mu_1, scale=se) - stats.norm.cdf(
x_lower, loc=mu_1, scale=se
)
print(f"\nType II error probability: β = {beta:.4f} ({beta * 100:.1f}%)")
print(f"Power (1 - β) = {1 - beta:.4f} ({(1 - beta) * 100:.1f}%)")Standard error: σ/√n = 15/√25 = 3.00 Critical z-value: ±1.960 Fail to reject H₀ if: 94.12 < X̄ < 105.88 Type II error probability: β = 0.6152 (61.5%) Power (1 - β) = 0.3848 (38.5%)
Let's visualize what's happening:

What Determines β?
The Type II error probability depends on four interrelated factors:
1. Effect size: The larger the true effect (the distance between and ), the smaller β becomes. Larger effects are easier to detect because the alternative distribution is further from the null distribution.
2. Sample size: Larger samples decrease β. More data reduces the standard error , making both distributions narrower and easier to distinguish.
3. Significance level: Lower α means higher β, all else equal. Making it harder to reject (requiring more extreme evidence) also makes it harder to detect true effects.
4. Population variability: Lower population variance (smaller σ) decreases β. Less noise means the signal is easier to detect.




Real-World Consequences of Type II Errors
Type II errors represent missed opportunities and can have serious consequences:
Medical diagnosis: A patient with early-stage cancer is told their screening test is negative. The cancer continues to grow undetected, potentially reaching a stage where treatment is less effective.
Drug development: A pharmaceutical company abandons an effective drug because their clinical trial failed to show a statistically significant benefit. Patients are deprived of a treatment that could help them.
Safety testing: An engineer fails to detect that a structural component is weaker than specifications require. The component is used in construction, potentially leading to failure under stress.
Criminal justice: A guilty person is acquitted due to insufficient evidence. While this is preferred to convicting the innocent, it still represents a failure of the justice system to hold offenders accountable.
Research: A scientist fails to detect a real relationship in their data. The discovery is delayed or never made, slowing scientific progress.