Two proportions calculator

Enter the count and sample size of two groups to compare their proportions as a difference, a relative risk and an odds ratio, each with a confidence interval, plus the z test and Fisher's exact test.

No accountInstant resultsA/B tests and trials

Enter the two groups

Independent groups, such as treatment and control, two survey segments or the two versions of an A/B test.

GROUPS AND OUTCOMES

LIVE RESULT

INSTANT

Difference between proportions

The groups must be independent. For the same people measured twice, or matched pairs, use McNemar's test instead.

Comparing two proportions

Two proportions can be compared on three scales, and each answers a different question. The risk difference p₁ − p₂ is the absolute change, in percentage points. The relative risk p₁ ÷ p₂ is the proportional change. The odds ratio compares odds rather than probabilities and is what logistic regression reports. The calculator gives all three with confidence intervals, plus the test of whether the proportions differ.

Difference: p₁ − p₂, with Newcombe's interval built from the two Wilson intervals
z test: z = (p₁ − p₂) ÷ √(p̄(1 − p̄)(1/n₁ + 1/n₂)), p̄ = pooled proportion; z² equals the chi-square statistic
Cohen's h = 2 asin √p₁ − 2 asin √p₂
Number needed to treat = 1 ÷ |p₁ − p₂|

Newcombe's hybrid score interval (method 10 in his 1998 paper) keeps close to its nominal coverage even with small groups or proportions near 0% or 100%, where the simple Wald interval fails. Results match Python's statsmodels (confint_proportions_2indep and proportions_ztest); Fisher's exact test, odds ratio and relative risk match SciPy and statsmodels.

Worked example

In an A/B test, 45 of 120 visitors converted with version A (37.5%) against 30 of 130 with version B (23.1%). The difference is 14.4 percentage points, 95% CI 3.0 to 25.4; z = 2.49, p = .013. On the relative scale, version A converts 1.63 times as often, 95% CI 1.10 to 2.40, and the odds ratio is 2.00.

The interval for the difference reaches from about 3 to 25 points: the test detects a difference, but its size is uncertain. A follow-up test with 80% power to detect a difference of this size (Cohen's h = 0.32) would need about 79 visitors per version; because effects that reach significance in small tests tend to be overestimated, planning for a smaller difference is safer.

Which measure to report

  • Risk difference and NNT are the most useful for decisions: a 5-point increase means 5 more successes per 100 people, and an NNT of 20 means treating 20 people for one extra success.
  • Relative risk is intuitive but can make small absolute changes sound large: going from 1% to 2% is a 100% increase but only one point.
  • Odds ratio is close to the relative risk only when the outcome is rare (below about 10%); for common outcomes it exaggerates the effect, so do not describe it as “times as likely”.
  • Cohen's h is the effect size for power analysis; 0.2, 0.5 and 0.8 are small, medium and large.

Small samples and more than two groups

When an expected count is below 5, use Fisher's exact test, which the calculator also reports. For three or more groups, or outcomes with more than two categories, enter the full table in the chi-square calculator. For a single proportion with its confidence interval, use the proportion confidence interval calculator.