Confidence Interval for a Proportion: Wilson, Exact (Clopper-Pearson) and Two-Proportion z-Test

Confidence intervals and tests for proportions.

Calculated from standard textbook formulas, with every step shown. The formulas are fixed, so the working does not need checking: what matters is the numbers you type in. Use these calculators only if you are competent to choose the inputs (loads, material strength, dimensions, supports) and check your units and assumptions. For learning and checking your own working: design and sign-off are for a qualified engineer. Drafting Central does not store the numbers you type.

How this calculator works

Choose one proportion or two.

Enter the number of successes and the sample size for each sample, and the confidence level.

The calculator gives the intervals by each method, or the z test, p-value, difference, relative risk and odds ratio.

Formulas used

  • \hat{p}\pm z\sqrt{\frac{\hat{p}(1 - \hat{p})}{n}}
  • z = \frac{\hat{p}_1 - \hat{p}_2}{\sqrt{\hat{p}(1 - \hat{p})(1/n_1 + 1/n_2)}}
  • RR = \frac{\hat{p}_1}{\hat{p}_2}

Worked example

With the default numbers in the calculator above:

  1. Sample proportion: 0.375 (37.5 %)
  2. Wald interval (the simple normal approximation; poor for small samples or proportions near 0 or 1): 0.28838 to 0.46162
  3. Wilson score interval (a good general choice): 0.29352 to 0.46423
  4. Agresti-Coull interval: 0.29344 to 0.46432
  5. Clopper-Pearson exact interval (the most cautious; it is a little wider): 0.28831 to 0.46801

Change the numbers in the calculator to see the full working, every step, for your own case.

A second worked example

A different case, with these numbers: What do you want? Compare two proportions; Number of successes in the first sample 60; Size of the first sample 100; Number of successes in the second sample (comparing) 45; Size of the second sample 100.

  1. The two sample proportions: 0.6 and 0.45
  2. Difference between the proportions: 0.15
  3. Pooled proportion (if there were no difference): 0.525
  4. Test statistic z: 2.124
  5. Two-tailed p-value: 0.03367
  6. Confidence interval for the difference: 0.01315 to 0.2868
  7. Relative risk (the ratio of the two proportions): 1.3333
  8. Odds ratio: 1.8333

Common questions

Which confidence interval for a proportion is best?

The Wilson interval is a good general choice. The exact Clopper-Pearson interval is the most cautious. The simple Wald interval is poor for small samples.

How do I compare two proportions?

Use a two-proportion z-test with the pooled proportion, or Fisher's exact test if the counts are small.

What is the relative risk?

The proportion in the first group divided by the proportion in the second.

Related calculators

Got a question about this? Ask an engineering question and get a plain-language answer with references.

Further reading: Any statistics text (inference for proportions).

Need a calculator we do not have?

Tell us what you would like to calculate. We read every request and build the most asked-for ones.

We store your request (and your email if you give it) to decide what to build. We do not store the numbers you type into calculators.

Embed this calculator on your own page

Copy this code into your page. The calculator runs inside the frame and links back to Drafting Central.

Need this drawn, designed or checked?

Drafting Central is a mechanical engineering and drafting business working with customers across Australia and around the world. A calculator gives you the numbers; we can turn them into drawings and designs.

Need help with a real project?

Talk to Drafting Central →

← All engineering calculators