Two Proportion Z-Test Calculator

Compare the proportions of successes in two independent groups. Enter the successes and sample size of each group to get the pooled z statistic, the p-value for a two-tailed, right-tailed or left-tailed test, a confidence interval for the difference p₁ − p₂ and Cohen's h.

Testing conversion rates of two page variants? The A/B test calculator adds relative uplift and a traffic-split check. Related guide: how hypothesis testing works.

A whole count, not a percentage

Compares p₁ with p₂

Chosen before looking at the data, usually 0.05

What the two-proportion z-test does

The two-proportion z-test asks whether the proportion of successes differs between two independent groups. The null hypothesis is H₀: p₁ = p₂, that both groups share one population proportion. The alternative hypothesis is p₁ ≠ p₂ for a two-tailed test, p₁ greater than p₂ for a right-tailed test and p₁ less than p₂ for a left-tailed test. Typical uses are the click rates of two page designs, the cure rates of two treatments, or the support for a policy in two regions.

Enter counts, not percentages: 30% of 400 is 120 successes. For conversion experiments with visitors and conversions, the A/B test calculator reports the same test with relative uplift and a check of the traffic split. To plan how many observations each group needs, use the A/B test sample size calculator.

Formulas

p̂₁ = x₁ / n₁, p̂₂ = x₂ / n₂

p̂ = (x₁ + x₂) / (n₁ + n₂) (pooled proportion)

SE = √( p̂ (1 − p̂) (1/n₁ + 1/n₂) )

z = (p̂₁ − p̂₂) / SE

Wald interval: (p̂₁ − p̂₂) ± z* √( p̂₁(1 − p̂₁)/n₁ + p̂₂(1 − p̂₂)/n₂ )

The test pools the two groups because the null hypothesis says they have the same proportion, so the best estimate of that proportion uses all the data. The confidence interval for the difference makes no such assumption and uses each group's own proportion. The Newcombe hybrid score interval combines the Wilson limits of the two groups, and the Agresti–Caffo interval adds one success and one failure to each group; both behave better than the Wald interval when counts are small or proportions are close to 0 or 1.

Each tail of the normal distribution is computed directly rather than as 1 minus the other tail, so a very small p-value keeps all its digits; one below 1e-300 is shown as a bound.

Conditions for the z-test

ConditionWhat to check
Random and independent groupsEach sample is random (or the groups come from a randomized experiment) and the two groups do not overlap
Independent observationsObservations within a group do not influence each other; without replacement, each n is less than 10% of its population
Success–failureAll four expected counts n₁·p̂, n₁·(1 − p̂), n₂·p̂ and n₂·(1 − p̂) are at least 10, using the pooled proportion

The calculator reports the smallest expected count under the results. When it is below 10, the normal approximation can be poor and Fisher's exact test is the safer choice: see the Fisher exact test calculator.

Worked example

A shop shows two page designs. Of 400 visitors who saw design A, 120 clicked; of 380 who saw design B, 90 clicked. Is the click rate different?

  1. p̂₁ = 120 / 400 = 0.3 and p̂₂ = 90 / 380 = 0.236842.
  2. Pooled proportion p̂ = 210 / 780 = 0.269231.
  3. SE = √(0.269231 × 0.730769 × (1/400 + 1/380)) = 0.031774.
  4. z = (0.3 − 0.236842) / 0.031774 = 1.9877.
  5. Two-tailed p-value = 2 × P(Z ≥ 1.9877) = 0.046845.

The p-value is just below 0.05, so at the 5% level the click rates differ significantly. The difference is 0.0632, and the 95% Wald interval for it is (0.0012, 0.1252): the whole interval is above 0, but the lower limit is close to 0, so the true difference could be tiny. Cohen's h is 0.1427, a small effect. Load example fills in these numbers.

Alternative hypothesisp-value
p₁ ≠ p₂ (two-tailed)0.046845
p₁ greater than p₂ (right-tailed)0.023423
p₁ less than p₂ (left-tailed)0.976577
Interval method95% interval for p₁ − p₂
Wald(0.0012, 0.1252)
Newcombe hybrid score(0.0009, 0.1246)
Agresti–Caffo(0.0008, 0.1247)

z-test, chi-square test and Fisher's exact test

For two groups the squared z statistic equals the chi-square statistic of the 2 × 2 table of successes and failures, so the two-sided p-values are identical. In R, prop.test(c(x1, x2), c(n1, n2), correct = FALSE) reports X-squared = z² and the same p-value; its default applies a continuity correction and gives a slightly larger one. The chi-square test of independence runs the same test from a contingency table. Fisher's exact test does not rely on a normal approximation and is the choice for small counts; the odds ratio and relative risk calculators describe the size of the difference in other terms.

Software equivalents

Softwarez-testInterval for p₁ − p₂
Excel / Sheetsz: =(p1-p2)/SQRT(p*(1-p)*(1/n1+1/n2)) with p = (x1+x2)/(n1+n2), p-value: =2*NORM.S.DIST(-ABS(z),TRUE)=(p1-p2)±NORM.S.INV(1-alpha/2)*SQRT(p1*(1-p1)/n1+p2*(1-p2)/n2)
Rprop.test(c(x1, x2), c(n1, n2), correct = FALSE)prop.test(...) prints a Wald-type interval; DescTools::BinomDiffCI(x1, n1, x2, n2, method = "score") for score intervals
Pythonstatsmodels: proportions_ztest([x1, x2], [n1, n2])statsmodels: confint_proportions_2indep(x1, n1, x2, n2, method="newcomb")
TI-84STAT → TESTS → 6:2-PropZTestSTAT → TESTS → B:2-PropZInt

To estimate one proportion or a difference without testing a hypothesis, use the proportion confidence interval calculator. For a single group against a target value, use the one proportion z-test.

Frequently Asked Questions

How do I calculate a two-proportion z-test?

Compute each group's proportion p̂₁ = x₁/n₁ and p̂₂ = x₂/n₂, pool them into p̂ = (x₁ + x₂)/(n₁ + n₂), and find the standard error √(p̂(1 − p̂)(1/n₁ + 1/n₂)). Then z = (p̂₁ − p̂₂)/SE, and the p-value is the area under the standard normal curve beyond z in the direction of the alternative hypothesis. Enter the four counts above to see every step.

Why does the test use the pooled proportion?

The null hypothesis says both groups have the same proportion, so under H₀ the best single estimate of it uses all the data. The confidence interval for the difference has no null value to lean on, so it uses each group's own proportion instead. That is why the test and a Wald interval can disagree when the p-value is close to α.

What are the null and alternative hypotheses?

H₀: p₁ = p₂. The alternative is p₁ ≠ p₂ (two-tailed), p₁ greater than p₂ (right-tailed) or p₁ less than p₂ (left-tailed). Group 1 is the group whose proportion appears first in the difference p₁ − p₂, so swapping the groups swaps the one-tailed directions but leaves the two-tailed p-value unchanged.

What is the difference between a two-proportion z-test and a chi-square test?

For two groups they are the same test: the squared z statistic equals the chi-square statistic of the 2 × 2 table (without continuity correction) and the two-sided p-values match. The z-test has the advantage of a direction, so it can be one-tailed, and it comes with an interval for the difference.

When should I use Fisher's exact test instead?

Use it when any expected count under the null hypothesis is small, roughly below 5 to 10, because the normal approximation behind the z-test is then unreliable. The calculator warns you when the smallest expected count is below 10. Fisher's exact test computes the p-value directly from the hypergeometric distribution.

How do I interpret the confidence interval for p₁ − p₂?

It is a range of plausible values for the true difference between the two proportions. If the interval for a two-tailed test at level 1 − α excludes 0, the difference is significant at level α; if it contains 0, the data are consistent with no difference. The width also shows how precisely the difference is estimated, which the p-value alone does not.

How do I run a 2-PropZTest on a TI-84?

Press STAT, choose TESTS, then 6:2-PropZTest. Enter x₁, n₁, x₂ and n₂ as whole numbers, choose the alternative (not equal, less than or greater than), and calculate. The z statistic, p-value and pooled proportion match this calculator. For the interval use B:2-PropZInt, which gives the Wald interval.

Embed This Calculator

Add this free calculator to your course page or LMS.

Adjust the height value to fit your page.