# Confidence Interval for a Proportion

> Free calculator for the confidence interval of a proportion. Enter x out of n and get the Wilson, Clopper-Pearson exact and Wald 95% CIs, a sentence and R code.

Canonical: https://biostatkit.com/confidence-interval-proportion

A confidence interval for a proportion gives the range of true values compatible with x events out of n people. The Wilson score interval is the usual choice; the Clopper-Pearson interval is exact and a little wider. The simple Wald interval, p ± 1.96 x sqrt(p(1 - p)/n), fails for small samples.

Enter how many people had the outcome out of how many were assessed and get the proportion with its Wilson score interval, the Clopper-Pearson exact interval and the Wald interval, a sentence for your manuscript, and the R code that reproduces the numbers.

## How the confidence interval of a proportion works

### What it is

A proportion such as a prevalence, a response rate or a sensitivity is x people out of n. Its confidence interval gives the range of true proportions that are compatible with the data. The width depends on n and on how close the proportion is to 0% or 100%.

### How this page computes it

With p = x/n and z the normal quantile for the confidence level (1.96 for 95%):

Wilson score: [ p + z²/(2n) ± z sqrt( p(1 - p)/n + z²/(4n²) ) ] / (1 + z²/n).

Clopper-Pearson exact: the limits are quantiles of the beta distribution, lower = B(α/2; x, n - x + 1) and upper = B(1 - α/2; x + 1, n - x), with lower = 0 when x = 0 and upper = 1 when x = n.

Wald: p ± z sqrt( p(1 - p)/n ), cut to between 0 and 1. It is shown for comparison only.

### Assumptions

- The n people are a simple random sample, or close to one, from the population you describe, and each is counted once.
- Each person either has the outcome or not.
- Cluster or weighted survey samples need a design-based interval, which is wider.

### Common mistakes

- Using the Wald interval with a small n or a proportion near 0% or 100%. It can even give a negative lower limit or a zero-width interval when x = 0.
- Reporting 0% with no interval when x = 0. The upper limit still tells the reader how high the true proportion could be.
- Entering a percentage instead of the count.

## Worked example

27 of 120 patients had the outcome.

p = 27 / 120 = 22.5%, z = 1.960.

Wilson 95% CI: 15.9% to 30.8%. Clopper-Pearson exact: 15.4% to 31.0%. Wald: 0.225 ± 1.96 x sqrt(0.225 x 0.775 / 120) = 15.0% to 30.0%.

### How to read the result

The data are compatible with a true proportion between about 16% and 31% (Wilson). The interval is not symmetric around 22.5%: Wilson and Clopper-Pearson correctly allow more room on the side away from 0%.

With 120 people the three methods are close. With small n or a proportion near 0% or 100% they differ more, and the Wald interval becomes unreliable.

## Methods wording

The proportion is reported with its 95% CI calculated by the Wilson score method [2] (BiostatKit [1]).

Method: Wilson score interval, Clopper-Pearson exact interval (beta quantiles), Wald interval for comparison.

## Frequently asked questions

### Wilson or Clopper-Pearson: which interval should I use?

Both are accepted. The Wilson interval is closer to the stated 95% coverage on average; the Clopper-Pearson interval is guaranteed to cover at least 95% and is therefore a little wider. Brown, Cai and DasGupta (2001) recommend Wilson. Name the one you report.

### What if no one had the outcome (x = 0)?

The proportion is 0%, and the lower limit is 0. The upper limit is still informative: with 0 of 25, the 95% Wilson upper limit is about 13%. For x = 0, the rule of three (3/n) gives a quick approximation of the upper limit.

### Why is the Wald interval not recommended?

It assumes the proportion is normally distributed around p, which fails for small samples and for proportions near 0% or 100%. Its true coverage can be well below 95%.

### How many people do I need for a narrower interval?

The width shrinks roughly with the square root of n: four times as many people halve the width. To plan a study around a target margin of error, use the sample size calculator for a proportion.

### Is my data stored or sent anywhere?

No. All calculations run in your browser tab. Nothing is uploaded, and the page works offline once loaded.

## Related calculators

- [Sample size for a proportion](https://biostatkit.com/sample-size-proportion): Participants needed to estimate a prevalence with a chosen margin of error.
- [Sensitivity and specificity calculator](https://biostatkit.com/sensitivity-specificity): Sensitivity, specificity, PPV, NPV and likelihood ratios with 95% CIs.
- [Chi-square test calculator](https://biostatkit.com/chi-square-test): Pearson and Yates chi-square, Fisher exact P and expected counts for a 2x2 table.
- [All BiostatKit calculators](https://biostatkit.com/)

## References

1. Wilson EB. Probable inference, the law of succession, and statistical inference. J Am Stat Assoc. 1927;22(158):209-212. doi:[10.1080/01621459.1927.10502953](https://doi.org/10.1080/01621459.1927.10502953)
2. Clopper CJ, Pearson ES. The use of confidence or fiducial limits illustrated in the case of the binomial. Biometrika. 1934;26(4):404-413. doi:[10.1093/biomet/26.4.404](https://doi.org/10.1093/biomet/26.4.404)
3. Newcombe RG. Two-sided confidence intervals for the single proportion: comparison of seven methods. Stat Med. 1998;17(8):857-872. doi:[10.1002/(SICI)1097-0258(19980430)17:8<857::AID-SIM777>3.0.CO;2-E](https://doi.org/10.1002/%28SICI%291097-0258%2819980430%2917:8%3C857::AID-SIM777%3E3.0.CO;2-E)
4. Brown LD, Cai TT, DasGupta A. Interval estimation for a binomial proportion. Stat Sci. 2001;16(2):101-133. doi:[10.1214/ss/1009213286](https://doi.org/10.1214/ss/1009213286)
5. von Elm E, Altman DG, Egger M, Pocock SJ, Gøtzsche PC, Vandenbroucke JP; STROBE Initiative. The Strengthening the Reporting of Observational Studies in Epidemiology (STROBE) statement: guidelines for reporting observational studies. Lancet. 2007;370(9596):1453-1457. doi:[10.1016/S0140-6736(07)61602-X](https://doi.org/10.1016/S0140-6736%2807%2961602-X)

Author: TS.BS. Vũ Duy Kiên (https://www.vuduykien.com)
