Z-Test Calculator

Z-Test Calculator

Test a sample proportion against a claimed value, or a sample mean when the population standard deviation is known, with the z statistic, p-value and 95% confidence interval.

z = (p̂ − p₀) ÷ √(p₀(1 − p₀) ÷ n)

Compares one sample’s proportion with a fixed value. To compare two groups, use the A/B test calculator.

Fill in all the boxes

What is a Z-Test?

A z-test checks whether a sample result differs from a claimed value by more than chance would explain, using the normal distribution. It applies when the standard error is known, which is the case for proportions and for means when the population SD is known.

The most common use is for proportions: does 56% preferring a new design really beat 50%? Does a 3% defect rate exceed the 2% target? Polls, quality checks and conversion rates all fit.

For means, the population SD is rarely known exactly, so the t-test is usually the right tool. Standardised tests with published norms, like IQ with SD 15, are the classic exception.

Z-Test Formula

As given in OpenStax Introductory Statistics, chapter 9. See Sources.

1. One proportion

p̂ = x ÷ n · z = (p̂ − p₀) ÷ √(p₀(1 − p₀) ÷ n)

2. One mean, σ known

z = (x̄ − μ₀) ÷ (σ ÷ √n)

3. p-value and interval

Two-tailed p = 2 × (1 − Φ(|z|))
95% CI for a proportion: p̂ ± 1.96 √(p̂(1 − p̂) ÷ n)

The test uses p₀ in the standard error; the interval uses p̂, which is why the two can occasionally disagree right at the boundary.

Worked Example: 560 of 1,000 Prefer the New Design

Given:
560 of 1,000 people shown two designs preferred the new one. Is that more than a 50/50 split?
Step 1:
Sample proportion and standard error:
p̂ = 0.56 · SE = √(0.5 × 0.5 ÷ 1,000) = 0.01581
Step 2:
z:
(0.56 − 0.5) ÷ 0.01581 = 3.79
Step 3:
Two-tailed p:
2 × (1 − Φ(3.79)) = 0.00015
Result:
z = 3.79, p = 0.00015

Very strong evidence of a genuine preference. The 95% interval, 53% to 59%, gives the plausible size of it.

Why Sample Size Decides a Z-Test

The same 56% preference, tested against 50% with different numbers of people.

z and p for 56% at different sample sizes
Peoplezp (two-tailed)
500.850.3961
1001.20.2301
2501.90.0578
5002.680.0073
1,0003.791.48e-4

Common Z-Test Mistakes

  • Using a z-test with a sample SD. If σ comes from your own data, the t-test is correct. With small samples, z overstates significance.
  • Small expected counts. With np₀ under about 10, the normal curve is a poor fit. Use an exact binomial test.
  • Testing two groups with a one-sample test. Comparing conversion in A against B needs a two-proportion test.
  • Entering a percentage as a count. "Successes" is the number of people, 560, not 56.

Z-Test FAQs

When should I use a z-test rather than a t-test?

For proportions, and for means only when the population standard deviation is genuinely known. Otherwise use a t-test.

How large a sample does a z-test need?

For proportions, np₀ and n(1 − p₀) should both be at least about 10. For means with known σ, normal data or n of about 30 or more.

Is a z-test the same as a one-proportion test?

For one proportion, yes: the one-proportion z-test is the standard large-sample test.

Why is the interval centred on p̂ but the test on p₀?

The test asks how surprising p̂ would be if p₀ were true, so it uses p₀’s spread. The interval estimates the true proportion, so it uses p̂.

Can I test against a proportion other than 50%?

Yes, any p₀ strictly between 0 and 1, such as a 2% defect target.

What does a negative z mean?

The sample result is below the hypothesised value.

How do I do this in Excel?

Calculate z with the formula, then =2*(1-NORM.S.DIST(ABS(z),TRUE)) for a two-tailed p. Excel’s Z.TEST function is for means with raw data.

What if I need an exact answer for a small sample?

Use the binomial distribution: the chance of x or more successes out of n when the true rate is p₀.

Sources

Related Tools