About the Z-Test Calculator
This z-test calculator tests a hypothesis about a population mean when the population standard deviation (σ) is known, or when samples are large enough that the sample standard deviation is a reliable stand-in. Choose a one-sample z-test to compare a sample mean with a target value, or a two-sample z-test to compare the means of two independent groups.
Enter the sample mean, σ and sample size for each group, the value stated in the null hypothesis, and whether the alternative is two-tailed, right-tailed or left-tailed. You get the z statistic, the p-value, the critical z at your significance level, a confidence interval for the mean (or difference) and a plain-English reject / fail-to-reject decision — the full output expected in an AP Statistics or intro stats hypothesis-testing question.
The z-test assumes independent observations and a normally distributed sampling mean, which holds when the data are normal or the sample is large (roughly n ≥ 30). If σ is unknown and the sample is small, use a t-test instead; for proportions, use a one- or two-proportion z-test.
With the default inputs, the z statistic is 2. Change any value above to recalculate instantly.
How to use the z-test calculator
- 1Choose a one-sample or two-sample z-test.
- 2Enter each sample mean, the population standard deviation and the sample size.
- 3Enter the value in the null hypothesis (the claimed mean, or 0 for no difference).
- 4Pick the alternative hypothesis and the significance level.
- 5Read z, the p-value and the decision; use the confidence interval to judge the size of the effect.
Formula and method
A z-test standardizes the gap between what you observed and what the null hypothesis claims by dividing it by the standard error of the mean. For one sample the standard error is σ/√n; for two independent samples the variances of the two means add, giving √(σ₁²/n₁ + σ₂²/n₂). Under H₀ the resulting z statistic follows the standard normal distribution.
The p-value is the normal tail area beyond z: both tails for a two-tailed test, the upper tail for a right-tailed test and the lower tail for a left-tailed test. H₀ is rejected when p < α, which is equivalent to z falling beyond the critical value (±1.96 for a two-tailed test at α = 0.05). The confidence interval is the estimate ± z(α/2) × SE.
- x̄
- Sample mean
- μ₀ / Δ₀
- Mean or difference stated in the null hypothesis
- σ
- Known population standard deviation
- n
- Sample size
- z
- Test statistic (standard normal under H₀)
Worked examples
IQ-style test: sample mean 105 vs. 100
With σ = 15 and n = 36, the standard error is 15 ÷ 6 = 2.5. The sample mean is 5 points above 100, so z = 5 ÷ 2.5 = 2.00. The two-tailed p-value is 0.0455, below 0.05, so H₀: μ = 100 is rejected.
Left-tailed fill-weight check
A machine should fill 500 g bags. A sample of 64 averages 498 g with σ = 8 g, so SE = 8 ÷ 8 = 1 and z = (498 − 500) ÷ 1 = −2. The left-tail p-value is 0.0228, so at α = 0.05 there is evidence the machine under-fills.
Two-sample z-test comparing two classes
The standard error of the difference is √(10²/50 + 12²/60) = √4.4 = 2.098. The 4-point gap gives z = 4 ÷ 2.098 = 1.91 and a two-tailed p-value of 0.0565, just above 0.05, so the difference is not significant; the 95% CI (−0.11 to 8.11) includes 0.
Frequently asked questions
When should I use a z-test instead of a t-test?+
Use a z-test when the population standard deviation σ is known, or when the sample is large (roughly 30 or more) so the sample SD estimates σ well. When σ is unknown and the sample is small, use a t-test, which accounts for the extra uncertainty with heavier-tailed critical values.
How do you calculate a z-test statistic?+
Subtract the hypothesized mean from the sample mean and divide by the standard error σ/√n. For example, x̄ = 105, μ₀ = 100, σ = 15 and n = 36 gives z = 5 ÷ 2.5 = 2.0.
What is the critical value for a z-test at 0.05?+
For a two-tailed test at α = 0.05 the critical values are ±1.96. For a one-tailed test at α = 0.05 the critical value is 1.645 (right-tailed) or −1.645 (left-tailed). At α = 0.01 they are ±2.576 two-tailed and 2.326 one-tailed.
How do I get the p-value from a z score?+
Find the area under the standard normal curve beyond your z. For a two-tailed test double the tail area beyond |z|; for a right-tailed test take the area above z; for a left-tailed test take the area below z. A z of 2.0 gives a two-tailed p-value of about 0.0455.
What are the assumptions of a z-test?+
Observations must be independent and randomly sampled, σ must be known (or n large), and the sampling distribution of the mean must be approximately normal — true if the population is normal or, by the central limit theorem, when n is large enough.