A z-test checks whether an observed mean or proportion is far enough from a hypothesised value to rule out chance. It works whenever the sampling distribution of the estimate is normal with a known standard error — either because the population standard deviation is known, or because the sample is large enough for the normal approximation to the binomial distribution to hold.
This calculator covers the four classic cases:
- One mean — compare a sample mean to a target when is known (a calibrated process, a standardised test with published );
- Two means — compare two independent groups whose population standard deviations are known;
- One proportion — compare an observed share to a reference proportion (a defect rate, a vote share, a conversion rate);
- Two proportions — compare two observed shares, using the pooled proportion as the null hypothesis requires.
For each test you get the z statistic, the p-value for the alternative you choose, the decision at your significance level, the critical value $z^*$ and a confidence interval for the parameter. If you only know the sample standard deviation of a small sample, use the t-test instead.
How to use this calculator
- Pick the test: one mean, two means, one proportion or two proportions.
- Enter the summary figures. For means: the sample mean, the population standard deviation σ and the sample size. For proportions: the number of successes and the sample size (not the percentage).
- Enter the value stated by the null hypothesis: μ₀, a difference Δ₀ (usually 0) or p₀ as a decimal.
- Choose the alternative: two-tailed (≠), left-tailed (<) or right-tailed (>). Decide this before looking at the data.
- Set α (0.05 by default) and read z, the p-value and the decision. Open the steps to see each intermediate value.
The formula
Every z-test has the same structure: the distance between the estimate and its null value, measured in standard errors.
| Test | Estimate | Standard error under |
|---|---|---|
| One mean | ||
| Two means | ||
| One proportion | ||
| Two proportions | , |
The p-value is for a two-tailed test, for a right-tailed test and for a left-tailed one. The confidence interval is $\text{estimate} \pm z^* \cdot SE$ with $z^* = \Phi^{-1}(1-\alpha/2)$; for proportions it uses the observed values (Wald interval) rather than or the pooled .
Worked example
One mean. IQ-type scores have . A class of 36 pupils averages 105; is that different from 100? , so and the two-tailed p-value is 0.0455. At α = 0.05 we reject ; the 95 % interval for the class mean is 100.10 to 109.90.
Two means. Group 1: , , ; group 2: , , . , , two-tailed 0.0086.
One proportion. 520 heads in 1,000 tosses against : , 0.2059 — no evidence the coin is biased.
Two proportions. 45 of 100 users clicked version A, 30 of 100 clicked version B. Pooled , , ; right-tailed 0.0142, so A performs significantly better at 5 %.
Z-test or t-test?
Use a z-test for a mean only when the population standard deviation is genuinely known — from a long production history, a published norm or a measurement system with a certified precision. When σ is estimated from the same sample, the extra uncertainty makes the statistic follow Student's t distribution, whose tails are heavier for small samples; the t-test then gives honest p-values. With more than about 30–50 observations the two tests give nearly the same answer, which is why large-sample tests are often called z-tests.
For proportions there is no t version: the z-test is the standard large-sample method, valid when the expected numbers of successes and failures are at least 5 (many textbooks prefer 10). With fewer, an exact binomial test is more reliable, and the calculator warns you.
Reading the result correctly
A significant z-test says the difference is unlikely to be pure sampling noise; it does not say the difference is large or important. With 100,000 observations a gap of 0.1 % can be "significant". Look at the confidence interval: it shows the range of parameter values compatible with the data, in the original units. A non-significant result, conversely, does not prove equality — check whether the interval is narrow enough to exclude differences that would matter. To plan a study with enough power, see the sample size calculator.
Frequently asked questions
When should I use a z-test?
Use it to compare a mean with a target when the population standard deviation is known, to compare two means with known standard deviations, or to test one or two proportions from reasonably large samples. If σ has to be estimated from a small sample, use a t-test.
Why is the pooled proportion used in the two-proportion test?
Under the null hypothesis both groups share the same true proportion, so the best estimate of that common value combines both samples: (x₁ + x₂)/(n₁ + n₂). The confidence interval for the difference does not assume equality, so it uses each sample’s own proportion.
What is the critical value of z at 5 %?
For a two-tailed test at α = 0.05 the critical values are ±1.96; for a one-tailed test they are 1.645 (right) or −1.645 (left). At 1 % they are ±2.576 and 2.326. The calculator shows z* for any α you enter.
How do I get the p-value from z?
For a two-tailed test, p = 2 × (1 − Φ(|z|)), where Φ is the standard normal distribution function. z = 2 gives p ≈ 0.0455; z = 1.96 gives 0.05. One-tailed p-values are half of that when z lies on the predicted side.
Can I enter percentages instead of counts?
The proportion tests need the number of successes and the sample size, because the standard error depends on n. If you only have a percentage, multiply it by n and round to the nearest whole number.
Sources
- OpenStax, Introductory Statistics 2e, §8.1 A Single Population Mean using the Normal Distribution
- OpenStax, Introductory Statistics 2e, §10.2 Two Population Means with Known Standard Deviations
- OpenStax, Introductory Statistics 2e, §10.3 Comparing Two Independent Population Proportions
- NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.4 Does the proportion of defectives meet requirements?
Last updated: