Statisticsdrill

Confidence intervals and tests Updated November 2026

Two-proportion z-test

A two-proportion z-test checks whether two sample proportions come from populations with the same proportion. Pool the successes to get p, compute z = (p1 - p2) / sqrt(p(1 - p)(1/n1 + 1/n2)), and find the p-value from the standard normal distribution.

Syntax

z = (p1 - p2) / sqrt( p * (1 - p) * (1/n1 + 1/n2) ),  p = (x1 + x2) / (n1 + n2)
PartWhat it is
p1, p2the two sample proportions, x1 / n1 and x2 / n2
pthe pooled proportion, all successes over all trials
n1, n2the two sample sizes

Examples

A: 50 of 500 converted (0.10). B: 65 of 500 (0.13)
p = 115 / 1000 = 0.115
SE = sqrt(0.115 * 0.885 * (1/500 + 1/500)) = 0.0202
z = (0.13 - 0.10) / 0.0202

Result: z = 1.49, two-sided p = 0.137

Excel: =2 * (1 - NORM.S.DIST(1.49, TRUE))

A: 50 of 1000 (0.05). B: 70 of 1000 (0.07)
p = 0.06; SE = sqrt(0.06 * 0.94 * 0.002) = 0.01062
z = 0.02 / 0.01062

Result: z = 1.88, two-sided p = 0.060

95% CI for the difference (unpooled SE)
0.03 +/- 1.96 * sqrt(0.1 * 0.9 / 500 + 0.13 * 0.87 / 500)

Result: -0.010 to 0.070

Common mistakes

  • Using the unpooled standard error in the test; the test assumes equal proportions under H0, so it pools (the confidence interval does not).
  • Testing with fewer than about 10 successes or failures in a group; use Fisher's exact test instead.
  • Comparing the two proportions by their separate confidence intervals; overlapping intervals do not mean no significant difference.

Practice Two-proportion z-test

These drills check your answer on live data, free, no account needed.

  • Two-proportion z testTwo branches piloted a cross-sell offer. Branch A: 46 of 200 customers accepted. Branch B: 84 of 600 accepted. Test H0: pA = pB against H1: pA ≠ pB. Find the z statistic (A minus B, pooled standard error), then decide at α = 0.01. Round to 2 decimal places.

Questions

Is the two-proportion z-test the same as a chi-square test?

For a 2 x 2 table, yes: the two-sided z-test gives the same p-value as the chi-square test, and chi-square = z^2.

What sample size do I need to detect a difference in proportions?

Per group, n = (z(alpha/2) + z(beta))^2 * [p1(1 - p1) + p2(1 - p2)] / (p1 - p2)^2. Detecting 10% vs 12% at 80% power needs about 3,800 per group.

Related

  • A/B test significanceHow to tell whether an A/B test result is statistically significant: compute relative lift, run the two-proportion z-test, read the p-value and avoid peeking.
  • Chi-square testHow to run a chi-square test of independence or goodness of fit: expected counts, sum of (O - E)^2 / E, degrees of freedom and p-value. Examples and Excel.
  • Confidence interval for a proportionHow to calculate a confidence interval for a proportion with p-hat plus or minus z times sqrt(p(1 - p) / n), worked survey examples and the conditions.
  • p-valueA p-value is the probability of a result at least as extreme as the observed one if the null is true. How to compute it from z and t, and common misreadings.

Previous: Chi-square testNext: A/B test significance