A z-test compares an estimate with a hypothesised value using the standard normal distribution. It applies when the standard deviation of the population is known – for example, from a long-run manufacturing process or a standardised test – or when the sample is large enough that the estimate of the standard deviation is very precise. The z-score says how many standard errors the sample mean lies from the claimed value.
Because the standard normal distribution does not depend on the sample size, z critical values are easy to remember: ±1.96 for a two-tailed test at α = 0.05, 1.645 for a one-tailed test, ±2.576 at α = 0.01. The p-value is the area of the normal curve beyond the observed z, in one tail or both.
The z-test assumes independent observations and either normal data or a sample large enough for the central limit theorem (often n ≥ 30). If σ is unknown and the sample is small, use a t-test instead – it accounts for the extra uncertainty from estimating σ. For proportions, the one-sample z-test is accurate when n·p₀ and n·(1 − p₀) are both at least about 10.
How to use the Z-Test Calculator
- Test
- Sample mean (x̄)
- Sample data
- Hypothesised mean μ₀ (or difference Δ₀ for two means)
- Population standard deviation (σ)
- Sample size (n)
- z-score
- Mean of sample 1
- σ of population 1
- Size of sample 1
- Mean of sample 2
- σ of population 2
- Size of sample 2
- Number of successes (x)
- Hypothesised proportion p₀
- Alternative hypothesis H₁
- Significance level (α)
Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.
How it works
Choose what you are testing and enter the sample mean, the hypothesised mean, the known σ and n (or the raw data, a z-score, two group summaries or a count of successes). The calculator computes the standard error and z, then reads the p-value and critical values from the standard normal distribution.
Worked example
A battery maker states a mean life of 20 hours with a known σ of 2.5 hours. A sample of 50 batteries averages 19.3 hours. SE = 2.5 ÷ √50 = 0.3536, so z = (19.3 − 20) ÷ 0.3536 = −1.980.
The two-tailed p-value is 0.0477, just below 0.05, and z lies beyond the critical value −1.960, so we reject H₀ at α = 0.05 – but not at α = 0.01 (critical ±2.576). The 95% confidence interval for the mean life is 18.61 to 19.99 hours.
z critical values
| Confidence / α | Two-tailed | One-tailed |
|---|---|---|
| 90% / 0.10 | ±1.645 | 1.282 |
| 95% / 0.05 | ±1.960 | 1.645 |
| 98% / 0.02 | ±2.326 | 2.054 |
| 99% / 0.01 | ±2.576 | 2.326 |
| 99.9% / 0.001 | ±3.291 | 3.090 |
Formula
One-sample mean: z = (x̄ − μ₀) ÷ (σ/√n) · Two means: z = (x̄₁ − x̄₂ − Δ₀) ÷ √(σ₁²/n₁ + σ₂²/n₂) · One proportion: z = (p̂ − p₀) ÷ √(p₀(1 − p₀)/n) · two-tailed p = 2(1 − Φ(|z|))
Worked example
Inputs — Test: One-sample mean – summary data; Sample mean (x̄): 19.3; Hypothesised mean μ₀ (or difference Δ₀ for two means): 20; Population standard deviation (σ): 2.5; Sample size (n): 50; Alternative hypothesis H₁: Two-tailed (H₁: not equal); Significance level (α): 0.05.
Results — p-value = 0.05; z-score = -1.9799; Decision = Reject H₀ at α = 0.05 – p = 0.0477 ≤ 0.05 and z = −1.9799 lies in the rejection region.; Critical z = ±1.96; Rejection region = z ≤ −1.96 or z ≥ 1.96; Estimate (x̄, x̄₁ − x̄₂ or p̂) = 19.3.
Key terms
- z-score
- The number of standard errors between the estimate and the hypothesised value.
- Standard normal distribution
- The normal distribution with mean 0 and standard deviation 1, written N(0, 1).
- Known σ
- A population standard deviation taken from long experience or a specification, not estimated from the sample.
- Central limit theorem
- The result that sample means are approximately normal for large samples, whatever the shape of the data.
Frequently asked questions
When should I use a z-test instead of a t-test?
When the population standard deviation is known, or for proportions. If you estimate σ from a small sample, use the t-test.
What is the z critical value for α = 0.05?
±1.960 for a two-tailed test, 1.645 for a right-tailed test and −1.645 for a left-tailed test.
What is the p-value for z = −2?
0.0228 for a left-tailed test and 0.0455 for a two-tailed test.
Can I use a z-test with a sample of 15?
Only if σ is known and the data are roughly normal. Otherwise the t-test is more honest about the uncertainty.
What does a negative z mean?
The sample estimate lies below the hypothesised value. In a two-tailed test only the size of z matters.
How is the two-sample z-test different?
It compares two means using both known population standard deviations: SE = √(σ₁²/n₁ + σ₂²/n₂).
Is a z-test the same as a z-score?
A z-score standardises one value; a z-test standardises a sample statistic (such as a mean) using its standard error and turns it into a p-value.