Z-Test Calculator
Run the four classic z-tests — one-sample mean, two-sample means, one proportion, and two proportions — and get the z statistic, the exact p-value, the critical value, and a plain-language decision at your significance level.
Related guides: what the p-value actually means and Type I vs Type II errors.
Before You Calculate
- Mean z-tests assume the population standard deviation σ is known. If you estimated it from the sample, use the t-test calculator instead.
- Proportion z-tests rely on the normal approximation; the calculator checks the np ≥ 10 and n(1 − p) ≥ 10 conditions for you.
- Choose the tail from the alternative hypothesis: two-tailed for “different from”, one-tailed for “greater than” or “less than”.
Related Calculators
Learn More
Hypothesis Testing
Learn how null and alternative hypotheses, p-values, confidence intervals, and test selection work together in statistical inference.
Type I vs Type II Errors
False alarms versus missed effects: how α and β trade off, what statistical power means, and a worked example that computes both error rates.
The Four Z-Test Formulas
Every z-test divides the gap between the estimate and its null value by the standard error of the estimate:
One-sample mean: z = (x̄ − μ₀) / (σ / √n)
Two-sample means: z = (x̄₁ − x̄₂) / √(σ₁²/n₁ + σ₂²/n₂)
One proportion: z = (p̂ − p₀) / √(p₀(1 − p₀)/n)
Two proportions: z = (p̂₁ − p̂₂) / √(p̂(1 − p̂)(1/n₁ + 1/n₂))
where p̂ in the last formula is the pooled proportion (x₁ + x₂)/(n₁ + n₂)
Under the null hypothesis each statistic follows the standard normal distribution, so the p-value is a tail area of the bell curve: the probability of a z at least this extreme when nothing real is going on. The proportion tests use p₀ (or the pooled estimate) in the standard error because the null hypothesis fixes the proportion, which is also why a confidence interval for a proportion uses a slightly different formula.
Z-Test or T-Test?
The mean z-tests are exact only when the population standard deviation is genuinely known — from a long production history, a national test design, or a measurement instrument with certified precision. When σ is estimated from the same sample being tested, the extra uncertainty makes the t-distribution the correct reference, and the t-test should be used. The distinction fades for large samples, where t and z critical values nearly coincide.
Proportion tests are a different story: the standard error of a proportion is determined by the proportion itself, so nothing extra is estimated and the z-test is the standard choice whenever the success/failure counts are large enough (np ≥ 10 and n(1 − p) ≥ 10 as a working rule).
Worked Example: One-Sample Mean
IQ scores are standardized with σ = 15. A school tests whether its program differs from the national mean of μ₀ = 100 and observes x̄ = 103.5 across n = 50 students.
- Standard error: 15 / √50 ≈ 2.1213.
- Z statistic: (103.5 − 100) / 2.1213 ≈ 1.6499.
- Two-tailed p-value: 2 × (1 − Φ(1.6499)) ≈ 0.0989.
- Decision: 0.0989 > 0.05, so the difference is not significant at the 5% level (the critical value ±1.96 was not reached).
Note how the tail choice matters: a right-tailed test of “the program raises scores” would give p ≈ 0.0494 and just cross the 5% threshold against a critical value of 1.645. Deciding the tail before seeing the data is what keeps that distinction honest.
Worked Example: Two Proportions
An A/B test shows variant A converting 45 of 100 visitors and variant B converting 30 of 100. Is the difference real?
- Sample proportions: p̂₁ = 0.45, p̂₂ = 0.30, difference 0.15.
- Pooled proportion: (45 + 30) / 200 = 0.375.
- Standard error: √(0.375 × 0.625 × (1/100 + 1/100)) ≈ 0.068465.
- Z statistic: 0.15 / 0.068465 ≈ 2.1909, two-tailed p ≈ 0.0285.
Since 0.0285 ≤ 0.05, the test rejects equal conversion rates at the 5% level. Entering x₁ = 45, n₁ = 100, x₂ = 30, n₂ = 100 in two-proportion mode reproduces each of these numbers.
Frequently Asked Questions
When should I use a z-test instead of a t-test?
Use a z-test for means only when the population standard deviation is known independently of your sample - from a standardized instrument, a long process history, or a designed scale like IQ. When the standard deviation is estimated from the sample itself, the t-test is the correct procedure. For proportions, the z-test is the standard large-sample choice because the null hypothesis itself determines the standard error.
What does the p-value from a z-test mean?
It is the probability of observing a z statistic at least as extreme as yours if the null hypothesis were true. A p-value of 0.03 means that only 3% of studies would show a difference this large by pure chance. It is not the probability that the null hypothesis is true, and it says nothing about how large or practically important the effect is.
How do I choose between one-tailed and two-tailed?
Let the research question decide before you look at the data. Test two-tailed when any difference matters ('the conversion rates differ'), and one-tailed only when a single direction was specified in advance ('the new design converts better'). A one-tailed test halves the p-value in the predicted direction but has zero power to detect the opposite effect, so switching tails after seeing the data invalidates the test.
Why does the one-proportion test use p0 rather than the sample proportion in the standard error?
A hypothesis test computes probabilities assuming the null hypothesis is true, and under that assumption the true proportion is p0 - so the spread of possible sample proportions is sqrt(p0(1 - p0)/n). Confidence intervals have no null hypothesis to lean on, which is why they plug in the sample proportion instead. For the same data, the two standard errors can differ slightly.
What sample size does a proportion z-test need?
The usual condition is np >= 10 and n(1 - p) >= 10 under the null hypothesis, which keeps the binomial distribution of counts close enough to a normal curve. This calculator enforces the rule and reports the failing product when the condition is not met. With small samples, use an exact binomial test instead - the binomial distribution calculator on this site computes those exact probabilities.
What is the pooled proportion in the two-proportion z-test?
Under the null hypothesis the two groups share a common proportion, and the best estimate of it combines both samples: (x1 + x2)/(n1 + n2). Using the pooled value in the standard error makes the test statistic match the null hypothesis it is testing. In the A/B example, 75 total conversions from 200 visitors give a pooled proportion of 0.375.