Z-Test Calculator

StatisticsLast updated: August 22, 2026

The z-test checks whether a sample mean departs significantly from a theoretical value (μ₀) in the situation where the population standard deviation σ is known. It applies when σ is reliably known from earlier data: calibrated measuring instruments, standardized tests, and production records accumulated over many years.

The test statistic is the observed difference divided by the standard error of the sampling distribution, and it is judged directly against the standard normal distribution; there is no notion of degrees of freedom. The calculator returns z, the p-value for the direction you choose, the critical z, confidence intervals for both the mean and the difference, and Cohen's d, and it shades the rejection region on a normal curve.

If you enter raw data, the mean and n are computed automatically and a histogram is drawn as well.
Separate the numbers with commas, spaces, or line breaks. A decimal comma is also accepted (3,14).
The population standard deviation that is known, or accepted from historical data. If it is unknown, a t-test rather than a z-test should be used.
The theoretical value or standard the mean is compared against.
Choose a directional hypothesis only if the direction of the difference can be justified in advance.
Sets the false-positive risk. In the social sciences 5% is the usual choice.
The probability that the interval covers the true parameter.

One-Sample z-Test Formulas

Hypotheses:       H₀: μ = μ₀   ·   H₁: μ ≠ μ₀ (two-tailed)
Standard error:   SE = σ / √n
Test statistic:   z = (x̄ − μ₀) / SE
Two-tailed p:     p = 2·[1 − Φ(|z|)]
Right-tail p:     p = 1 − Φ(z)        Left-tail p: p = Φ(z)
Critical value:   two-tailed ±z₍₁−α/₂₎ · one-tailed z₍₁−α₎
Confidence int.:  x̄ ± z₍₁−α/₂₎ · σ/√n
Effect size:      d = (x̄ − μ₀) / σ

Frequently used critical values: 1.645 for 90% · 1.960 for 95% · 2.576 for 99% (two-tailed). These values do not depend on sample size, because the z-test has no degrees of freedom.

How to Calculate

  1. Enter the population standard deviation (σ); this value must come from historical records or from the known properties of the measuring instrument.
  2. Paste the raw data, or switch to summary mode and type the sample mean and n.
  3. Set the test value (μ₀) the mean is to be compared against.
  4. Choose the hypothesis direction, the significance level (α), and the confidence level.
  5. Compare z with the critical z, and see on the shaded normal curve whether z falls inside the rejection region.
  6. Report the confidence interval and Cohen's d; if you have any doubt about σ, check the result with a t-test as well.

Worked Examples

Mean shift on a standardized test

The mean of the 12-person sample is 111.67. With σ = 15 known, the standard error is 4.33 and z = 2.694; the two-tailed test gives p = 0.007 and H₀ is rejected. The 95% confidence interval for the mean runs from 103.18 to 120.15 and does not cover 100; Cohen's d = 0.778 is a medium effect.

z statistic: 2.6943 · p-value: p = 0.007 · Critical z (α = 0.05): ±1.9600

Large sample from summary statistics

With n = 400 and σ = 15 the standard error is only 0.75; a difference of 1.50 units produces z = 2.000 and a two-tailed p = 0.046, so H₀ is rejected. Cohen's d = 0.100, on the other hand, makes the effect negligible. The 95% confidence interval for the mean runs from 100.03 to 102.97; this example shows plainly how a difference of no practical importance can still come out significant in a large sample.

z statistic: 2.0000 · p-value: p = 0.046 · Critical z (α = 0.05): ±1.9600

Left-tailed test — package fill weight

The mean of 40 packages is 497.50 grams and the known process standard deviation is 6 grams. The standard error is 0.9487, so z = -2.635, and the left-tailed test gives p = 0.004: the mean fill weight is below 500 grams. The 95% confidence interval for the difference runs from about -4.36 to -0.64 grams and does not cover zero; Cohen's d = -0.417 is a small effect.

z statistic: -2.6352 · p-value: p = 0.004 · Critical z (α = 0.05): -1.6449

Frequently Asked Questions

What exactly is the difference between a z-test and a t-test?
The distinction sits at a single point: where the standard deviation in the denominator comes from. The z-test treats the population standard deviation σ as a KNOWN constant and judges the test statistic against the standard normal distribution. The t-test, not knowing σ, estimates it from the sample as s; because that estimate carries variability of its own, the reference distribution becomes the heavier-tailed t distribution and degrees of freedom enter the picture. In practice σ is almost never known, which is why the t-test is used far more often.
When should I prefer a z-test over a t-test?
When σ is genuinely known from an external source: standardized intelligence or achievement tests (σ = 15, for example), production lines monitored long enough for the process capability to be established, and measuring instruments whose standard deviation is stated on a calibration certificate. Outside those cases, computing σ from the sample and then running a z-test is a methodological error that makes the p-value look smaller than it is.
Do z and t give the same result when n is large?
Yes, they converge in practice. As the degrees of freedom rise, the t distribution approaches the standard normal: the two-tailed 5% critical value is 2.042 at df = 30, 1.984 at df = 100, and 1.960 at infinity. Around n ≥ 100 the p-values of the two tests differ only past the third decimal. Even so, if σ is unknown the t-test remains the correct choice in a large sample too; the difference is small, but the reasoning does not change.
Is a z-test valid with a small sample?
Yes if σ is truly known, but with one condition: when n < 30 you cannot lean on the central limit theorem, so the population itself must be approximately normal. If the population is clearly skewed, the p-value of a z-test on a small sample is not trustworthy. In that case you either enlarge the sample or move to a nonparametric method.
Why are the critical z values always the same?
In a z-test the reference distribution is always the standard normal, and it does not change with sample size. That is why the two-tailed boundary is always ±1.96 for 5%, ±2.576 for 1%, and 1.645 for a one-tailed 5% test. Sample size affects the standard error (σ/√n), not the critical value; as n grows the denominator shrinks and the same difference produces a larger z.
Why do the p-value and the confidence interval always agree?
A two-tailed z-test and the interval at the matching confidence level are mathematically equivalent. If a two-tailed test at α = 0.05 rejects H₀, the 95% confidence interval does not cover μ₀; if it cannot reject H₀, the interval does cover it. Since the confidence interval additionally conveys the size of the effect, reporting it alongside the p-value is recommended.
How do I run a z-test in Excel and R?
In Excel, Z.TEST(array, μ₀, σ) returns the one-tailed (right-tail) p-value; for a two-tailed test, double the result or subtract it from 1 and double that. For the critical value use NORM.S.INV(1 − α/2). Base R has no ready-made z.test; the z.test(x, mu = 100, sigma.x = 15) command from the BSDA package, or computing 2*pnorm(-abs(z)) directly, gives the same result.