Z-Test Calculator

Test whether an observed value differs significantly from a hypothesized population value—for means when you know σ, and for proportions. No signup required.

One-sample mean inputs
Z
P-VALUE
CRITICAL Z
Enter values to calculate.
Standard normal distribution with rejection region shaded
Fig. 1 — Standard normal distribution. The shaded region(s) represent the rejection zone(s) at α = 0.05.

How This Was Calculated

The Formula

z = (x̄ − μ₀) / (σ / √n)
z
the standardized test statistic
sample mean
μ₀
hypothesized population mean
σ
population standard deviation (known)
n
sample size

Worked Example

One-sample mean test

A manufacturer claims that light bulbs have a mean lifespan of μ₀ = 1000 hours with population σ = 80 hours. You test n = 36 bulbs and find x̄ = 1010 hours. Is there evidence that the mean differs from the claim?

z = (1010 − 1000) / (80 / √36) = 10 / 13.333 = 0.75

For a two-tailed test, p = 2(1 − normCDF(0.75)) ≈ 0.4532. At α = 0.05, we fail to reject H₀: the data do not provide evidence that the mean lifespan differs from 1000 hours.

Assumptions & When This Test Is Wrong

Critical: Known population σ

The z-test applies only when the population standard deviation σ is genuinely known beforehand. This is rare outside standardized testing (SAT, IQ scales) and quality-control contexts. In most real studies, you estimate σ from your sample, making your estimate s, not σ. When you use s in place of σ, use the t-test instead.

Normality

For small samples (n < 30), the underlying population should be approximately normal. For large samples, the Central Limit Theorem allows the z-test to work even if the population is not normal.

Independence

Observations must be independent. If you sample without replacement, the sample size should be less than 10% of the population size.

Proportions: Large counts

For proportion tests, the expected counts n·p₀ and n·(1 − p₀) should both be at least 5 (or 10 for stricter applications). The z-test relies on the normal approximation to the binomial.

Frequently Asked Questions

When do I use a z-test vs. a t-test?

Use a z-test when the population standard deviation σ is known. Use a t-test when you estimate the standard deviation from your sample. In practice, you almost always know only the sample standard deviation s, making the t-test the more common choice. If you are unsure, use the t-test.

Can I use a z-test for proportions?

Yes. The z-test for proportions does not require a known population σ; instead, it uses the binomial variance p(1 − p). You do need the expected counts (n·p₀ and n·(1 − p₀)) to be at least 5. For smaller samples, use an exact binomial test.

How large does n need to be for a z-test on means?

If the population is approximately normal, any n ≥ 1 works. If the population is non-normal, the Central Limit Theorem suggests n ≥ 30, though the exact threshold depends on how non-normal the population is. Always examine your data visually first.

What is the difference between one-tailed and two-tailed?

A two-tailed test asks "Does the statistic differ from the hypothesis, in either direction?" A one-tailed test asks "Is the statistic greater than (or less than) the hypothesis?" Two-tailed tests are the default unless you have a strong reason to predict a specific direction beforehand. Beware of choosing a tail after seeing your data—that is p-hacking.

What if I don't know the population standard deviation?

Then you estimate it from your sample (call it s) and use the t-test instead. This is the most common scenario in practice. The z-test assumes σ is a known constant, not an estimate.

What is the p-value, and what does it mean?

The p-value is the probability of observing a test statistic at least as extreme as yours, if the null hypothesis were true. A small p-value (e.g., p < 0.05) suggests your data are unlikely under H₀, so you reject H₀. A large p-value means your data are consistent with H₀, and you fail to reject it. The p-value is not the probability that H₀ is true.

Sources