Written by Dackohn; last reviewed November 2026.

A z-test compares a mean with a target, or two means, when the population SD is known: z = (x̄ − μ) / (σ / √n). For a sample of 49 with mean 503, μ = 500 and σ = 10, z = 2.10 and p = .036. If you estimated the SD from the sample, use a t-test.

When to use a z-test

The key condition is a known population SD. Examples include a machine with a long, stable record, or a standardised test with a published SD. If you calculated the SD from your own sample, use a t-test, whatever the sample size. See t-test vs z-test.

One-sample example

A machine should fill bottles to 500 ml, with a known σ of 10 ml. A sample of 49 bottles has a mean of 503 ml.

  1. Hypotheses: H₀: μ = 500. H₁: μ ≠ 500.
  2. Standard error: 10 / √49 = 1.4286.
  3. z statistic: (503 − 500) / 1.4286 = 2.10.
  4. p-value: the z-table gives Φ(2.10) = 0.9821, so p = 2 × (1 − 0.9821) = .036.
  5. Conclusion: since .036 < .05, the machine appears to be overfilling.
  6. Confidence interval: 3 ± 1.96 × 1.4286 gives 0.2 to 5.8 ml. The effect could be tiny, so check whether it matters in practice.

Two-sample example

Two exam boards have known SDs of 10 and 12. Samples have means 72 (n = 50) and 68 (n = 60).

  1. Standard error: √(10² / 50 + 12² / 60) = √(2 + 2.4) = 2.098.
  2. z statistic: (72 − 68) / 2.098 = 1.91.
  3. p-value: .057, just above .05, so the difference is not significant at the 5% level.

Critical values

Instead of a p-value, you can compare z with a critical value: ±1.96 for a two-tailed test at α = .05, or 1.645 for a one-tailed test.

In Excel

Two-tailed p-value: =2*(1-NORM.S.DIST(ABS(z),TRUE)). Excel’s Z.TEST function returns a one-tailed value, which often catches people out.

Common mistakes

Try it yourself

Z-Test Calculator →One-sample and two-sample tests with a confidence interval. Two-Proportions Calculator →The z-test for comparing percentages.

Frequently asked questions

What is the formula for a z-test?

z = (sample mean - population mean) / (population SD / square root of n).

What is the difference between a z-test and a t-test?

A z-test uses a known population SD. A t-test estimates the SD from the sample and uses the heavier-tailed t-distribution.

Is a z-test used for proportions?

Yes. The two-proportion z-test compares percentages, with a standard error based on the proportions.

Related reading: T-test vs z-test · How to calculate a z-score · Critical values explained


Sources & further reading: NIST/SEMATECH e-Handbook of Statistical Methods · OpenStax Introductory Statistics. How we compute & validate: methodology. Written & reviewed by Dackohn; last reviewed August 2026.