Skip to content

Z-Test Calculator for Means and Proportions

One- and two-sample z-tests for means (known σ) and proportions: z statistic, p-value, critical value and confidence interval.

Your details

Test

Known from long experience or a specification. If you only have the sample standard deviation s, use a t-test instead.

Alternative hypothesis H₁

0.05 means 5 % (95 % confidence).

Results update as you type

z statistic

2

p-value
0.0455
Decision at level α
Reject H₀
Critical value z*
±1.96
Estimate (x̄, x̄₁ − x̄₂, p̂ or p̂₁ − p̂₂)
105
Standard error used in z
2.5
Confidence interval (1 − α): lower limit
100.10009
Confidence interval (1 − α): upper limit
109.89991

p = 0.0455 ≤ α = 0.05: the result is statistically significant at this level.

Step-by-step solution
  1. x̄ = 105
  2. SE = σ/√n = 2.5
  3. z = (105 − 100) / 2.5 = 2
  4. p = 2 × P(Z ≥ |2|) = 0.0455
  5. 105 ± 1.96 × 2.5 → [100.10009 ; 109.89991]

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 σ\sigma 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 xˉ\bar x to a target μ0\mu_0 when σ\sigma is known (a calibrated process, a standardised test with published σ\sigma);
  • Two means — compare two independent groups whose population standard deviations are known;
  • One proportion — compare an observed share p^=x/n\hat p = x/n to a reference proportion p0p_0 (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

  1. Pick the test: one mean, two means, one proportion or two proportions.
  2. 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).
  3. Enter the value stated by the null hypothesis: μ₀, a difference Δ₀ (usually 0) or p₀ as a decimal.
  4. Choose the alternative: two-tailed (≠), left-tailed (<) or right-tailed (>). Decide this before looking at the data.
  5. 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.

z=estimate−null valueSEz = \frac{\text{estimate} - \text{null value}}{SE}
Test Estimate Standard error under H0H_0
One mean xˉ\bar x σ/n\sigma / \sqrt{n}
Two means xˉ1−xˉ2\bar x_1 - \bar x_2 σ12/n1+σ22/n2\sqrt{\sigma_1^2/n_1 + \sigma_2^2/n_2}
One proportion p^=x/n\hat p = x/n p0(1−p0)/n\sqrt{p_0(1-p_0)/n}
Two proportions p^1−p^2\hat p_1 - \hat p_2 p^(1−p^)(1/n1+1/n2)\sqrt{\hat p(1-\hat p)(1/n_1 + 1/n_2)}, p^=x1+x2n1+n2\hat p = \frac{x_1 + x_2}{n_1 + n_2}

The p-value is 2 P(Z≥∣z∣)2\,P(Z \ge |z|) for a two-tailed test, P(Z≥z)P(Z \ge z) for a right-tailed test and P(Z≤z)P(Z \le z) 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 p^\hat p values (Wald interval) rather than p0p_0 or the pooled p^\hat p.

Worked example

One mean. IQ-type scores have σ=15\sigma = 15. A class of 36 pupils averages 105; is that different from 100? SE=15/36=2.5SE = 15/\sqrt{36} = 2.5, so z=(105−100)/2.5=2.00z = (105 - 100)/2.5 = 2.00 and the two-tailed p-value is 0.0455. At α = 0.05 we reject H0H_0; the 95 % interval for the class mean is 100.10 to 109.90.

Two means. Group 1: xˉ1=52\bar x_1 = 52, σ1=8\sigma_1 = 8, n1=40n_1 = 40; group 2: xˉ2=48\bar x_2 = 48, σ2=6\sigma_2 = 6, n2=50n_2 = 50. SE=1.5232SE = 1.5232, z=2.626z = 2.626, two-tailed p=p = 0.0086.

One proportion. 520 heads in 1,000 tosses against p0=0.5p_0 = 0.5: z=1.265z = 1.265, p=p = 0.2059 — no evidence the coin is biased.

Two proportions. 45 of 100 users clicked version A, 30 of 100 clicked version B. Pooled p^=0.375\hat p = 0.375, SE=0.0685SE = 0.0685, z=2.191z = 2.191; right-tailed p=p = 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

Last updated:

More Statistics calculators

People also use