Z-Test
Z-Test
Definition
Core Statement
A Z-Test is a statistical test used to determine whether a sample mean differs significantly from a population mean when the Population Standard Deviation (
Z-Test vs T-Test
| Feature | Z-Test | T-Test |
|---|---|---|
| Standard Deviation | Known ( |
Unknown (use sample |
| Sample Size | Large ( |
Any (esp. Small |
| Distribution | Standard Normal ( |
Student's |
Practical Reality
In real life, we almost never know the true population
One-Sample Z-Test Example
IQ Test
National Average IQ = 100,
A school samples 50 students with Mean IQ = 105.
Calculation:
Decision:
- Critical Z (95% confidence) = 1.96.
. Reject Null. - This school is significantly smarter than average.
Two-Proportion Z-Test
This is the most common real-world use case for Z-tests (A/B Testing).
Used for comparing two conversion rates (
Python Implementation
from statsmodels.stats.weightstats import ztest
# 1. One Sample Mean
# (Requires raw data, treats sample std as population std if n is large)
stat, p = ztest(data, value=100)
# 2. Proportions (A/B Test) - The more common use
from statsmodels.stats.proportion import proportions_ztest
count = [30, 45] # Successes
nobs = [1000, 1000] # Total observations
z_stat, p_val = proportions_ztest(count, nobs)
Related Concepts
- One-Sample t-test - The alternative for unknown
. - Central Limit Theorem (CLT) - Justifies the Normal approx.
- A/B Testing - Uses Two-Proportion Z-test.