Z-Test and t-Test: When to Use Each (With Examples)
The z-test and the t-test both ask "is this sample mean significantly different from a claimed value?" — but they apply in different situations. The z-test is used when the population standard deviation σ is known; the t-test when σ is unknown and estimated from the sample.
This distinction matters because in real life σ is almost never known. Using a z-test with an estimated standard deviation pretends you know more than you do, producing p-values slightly too small. The t-test corrects for that extra uncertainty with heavier tails.
Key Concepts
- z-distribution: the standard normal curve (mean 0, sd 1). Used when σ is known exactly, for example from long historical records.
- t-distribution: a family of curves indexed by degrees of freedom (df = n − 1). Heavier tails than the normal, accounting for the uncertainty in estimating σ from s.
- Degrees of freedom: roughly, the number of independent pieces of information. One degree is "spent" estimating the mean, leaving n − 1.
- Large-sample rule: when n ≥ 30, the t-distribution is nearly identical to the normal, so the two tests give almost the same answer.
Formulas
- z-test: z = (x̄ − μ₀) / (σ / √n). Compare with standard normal critical values (for example ±1.96 at α = 0.05, two-sided).
- t-test: t = (x̄ − μ₀) / (s / √n), df = n − 1. Critical values are larger than z values for small n.
Assumptions: random sampling; approximately normal population for small samples.
Worked Example
A class of 25 students scores x̄ = 102 on a test where the national average is claimed to be μ₀ = 100, with sample sd s = 10. Test H₀: μ = 100 vs H₁: μ ≠ 100 at α = 0.05. (σ is unknown, so use the t-test.)
- Standard error: s / √n = 10 / 5 = 2.0.
- Test statistic: t = (102 − 100) / 2.0 = 1.00, df = 24.
- Critical value: t* = 2.064 for df = 24, two-sided α = 0.05.
- Decision: |1.00| < 2.064, so fail to reject H₀.
- Conclusion: the class average of 102 is not significantly different from 100 — it could easily be sampling luck.
Common Misconceptions
- "The t-test is only for small samples" is wrong. The t-test is for whenever σ is unknown, at any sample size — it just matters most when n is small.
- "The z-test is more accurate" is wrong too. With σ estimated from data, the z-test is overconfident; the t-test is the honest choice.
Real-World Applications
- Lab experiments: a chemist with 8 measurements and no known σ uses the t-test to check a reaction yield.
- Quality control: a bottling plant with decades of σ records can use the z-test on each hour's sample mean.
- Sports science: testing whether 12 athletes' average sprint time improved after a training block.
Use the z-test when σ is known and the t-test when it is estimated from the sample — in practice, that means the t-test almost always. The heavier tails of the t-distribution are simply honesty about what you do not know.
Related blogs
- Population and Sample: Statistics Basics Explained
- Sampling Methods: Random, Stratified & Cluster Guide
- Sampling Distributions: Mean, Proportion & CLT Guide
- Standard Error Explained: Formula, Uses and vs Standard
- Point Estimation: MLE and Method of Moments Explained
- Confidence Intervals: Concepts, Formulas and Examples