One-Sample Z-Test
Hypothesis Testing
The Classic Test When σ is Known
The one-sample z-test compares a sample mean to a hypothesized population mean when the population standard deviation is known. It is the foundation for understanding all parametric hypothesis tests.
- Manufacturing — Testing whether production meets specified standards with known process variability
- Benchmarking — Comparing performance against established population parameters
- Regulatory Compliance — Verifying products meet labeled specifications
The z-test is the simplest parametric test — master it first.
The one-sample z-test tests whether a population mean equals a hypothesized value when the population standard deviation (σ) is known and the sample is large (n ≥ 30).
Assumptions
Step-by-Step Procedure
Critical Region Visualization
x = np.linspace(-4, 4, 1000)
y = stats.norm.pdf(x)
fig, ax = plt.subplots(figsize=(10, 5))
ax.plot(x, y, 'b-', linewidth=2)
# Rejection regions (two-tailed, α=0.05)
ax.fill_between(x, y, where=x <= -z_crit, alpha=0.4, color='red', label=f'Reject H₀ (each α/2={alpha/2})')
ax.fill_between(x, y, where=x >= z_crit, alpha=0.4, color='red')
ax.fill_between(x, y, where=(-z_crit <= x) & (x <= z_crit), alpha=0.2, color='blue', label='Fail to reject H₀')
ax.axvline(z, color='green', linewidth=2, linestyle='--', label=f'Observed z = {z:.3f}')
ax.axvline(-z_crit, color='black', linewidth=1.5, linestyle=':')
ax.axvline(z_crit, color='black', linewidth=1.5, linestyle=':', label=f'z* = ±{z_crit:.3f}')
ax.set_title(f'One-Sample Z-Test (Two-Tailed, α={alpha})')
ax.set_xlabel('z')
ax.set_ylabel('Density')
ax.legend()
plt.tight_layout()
plt.savefig('z_test.png', dpi=150)
plt.show()