Calculator
Enter the number of successes and the sample size to get both intervals.
Explanation
When we want to estimate the true proportion of a characteristic in a population (defect rate, percentage of satisfied users, prevalence of a disease…), the confidence interval for a proportion gives us the plausible range for that value.
The sample proportion \(\hat{p} = x/n\) (successes among observations) is the estimator. There are several methods for building the interval; the most common are Wald (normal approximation) and Wilson (more accurate for extreme proportions or small samples).
Let \(C\) denote the confidence level and \(\alpha=1-C\) the total area outside the interval. For 95% confidence, \(C=0.95\), \(\alpha=0.05\) and \(\alpha/2=0.025\) in each tail.
Wald method (normal approximation)
Wald applies the normal approximation directly to the sample proportion \(\hat{p}\). It is the simplest interval and the easiest to compute by hand:
\( \hat{p} \pm z_{\alpha/2} \cdot \sqrt{\dfrac{\hat{p}(1-\hat{p})}{n}} \)
It works reasonably well when the sample is large and the proportion isn't close to 0 or 1. As a practical rule, it is advisable to require \(n\hat{p} \geq 5\) and \(n(1-\hat{p}) \geq 5\), although with moderate sample sizes this rule doesn't always guarantee good actual coverage.
Its main limitation is that it centers the interval exactly on \(\hat{p}\) and uses a standard error estimated only from \(\hat{p}\). Because of this it can produce bounds below 0 or above 1, and it can underestimate the uncertainty when there are few successes, few failures, or extreme proportions.
Wilson method (score, recommended)
Wilson starts from the score test for a proportion and works out which values of \(p\) would be compatible with the data. It doesn't simply add and subtract the same margin around \(\hat{p}\); the center of the interval shifts slightly toward less extreme values and the bounds stay within \([0,1]\).
\( \dfrac{\hat{p} + \dfrac{z^2}{2n} \pm z\sqrt{\dfrac{\hat{p}(1-\hat{p})}{n} + \dfrac{z^2}{4n^2}}}{1 + \dfrac{z^2}{n}} \)
Wilson is generally recommended because it better maintains the actual coverage of the confidence level, especially with small samples or proportions close to 0 or 1. It also correctly handles extreme cases such as \(x=0\) or \(x=n\), where Wald can give degenerate or uninformative intervals.
Worked example
In a survey of 200 customers, 134 report being satisfied. \(\hat{p} = 134/200 = 0.67\). With 95% confidence (\(C=0.95\), \(\alpha=0.05\), \(z_{0.025}=1.960\)):
With Wald, the standard error is \(\sqrt{0.67\cdot0.33/200}\approx0.03325\), and the interval is:
\( 0.67 \pm 1.960 \cdot 0.03325 \approx [0.605,\; 0.735] \)
With Wilson, applying the score formula to the same \(x=134\), \(n=200\) and \(z=1.960\), we get:
\( CI_{Wilson} \approx [0.602,\;0.731] \)
In this example both methods are similar because the sample is large and the proportion isn't extreme. If we had observed very few successes, very few failures, or a small sample, the difference would be larger and Wilson would be the more reliable choice.
Assumptions for the CI of a proportion
- The data must come from Bernoulli trials: each observation is classified as success or failure.
- The observations must be independent; if sampling without replacement from a finite population, the sample should be small relative to the population or a specific correction should be applied.
- The probability of success must be the same for all observations within the analyzed group.
- For Wald, enough successes and failures are needed: \(n\hat p\ge 5\) and \(n(1-\hat p)\ge 5\). Wilson is more reliable when this condition is doubtful.
Differences between Wald and Wilson
| Aspect | Wald | Wilson |
|---|---|---|
| Idea | Direct normal approximation of \(\hat{p}\). | Score interval: values of \(p\) compatible with the data. |
| Center | Centered on \(\hat{p}\). | Center adjusted toward less extreme values. |
| Bounds | Can fall outside \([0,1]\). | Stays within \([0,1]\). |
| When to use it | Large samples, non-extreme proportions and quick computation. | Recommended for general use; especially if \(n\) is small, \(\hat{p}\) is extreme, or there are few successes/failures. |
In short: Wald is useful as a quick, didactic approximation; Wilson is preferable as the main result because it better respects the binomial nature of the data and avoids impossible bounds.
When to use each method?
- Use Wilson by default if you want a robust interval for most situations.
- Use Wald only as a quick approximation when \(n\) is large and there are enough successes and failures.
- Avoid Wald if \(x=0\), \(x=n\), \(n\) is small, or \(\hat{p}\) is close to 0 or 1.
- Compare both if you are in an intermediate zone: if they differ a lot, interpret Wald with caution and prioritize Wilson.
How to interpret the result
The interval \([L, U]\) is the range of values of the population proportion \(p\) compatible with the observed data at the chosen confidence level. In frequentist terms: if you repeated the sampling many times and built the CI with the same method, a proportion \(C\) of those intervals would contain the true value of \(p\). The width depends on the sample size \(n\) and on the estimated proportion itself \(\hat{p}\): variability is greatest when \(\hat{p} = 0.5\) and decreases as it moves away from that value. In the chart, the green region under the standard normal curve is the confidence zone and the red tails (area \(\alpha/2\) each) delimit the critical values \(\pm z_{\alpha/2}\).
To halve the width of the interval while keeping the same confidence level, you need to quadruple the sample size, since the margin of error is proportional to \(1/\sqrt{n}\). Increasing confidence from 95% to 99% widens the interval because \(z_{0.005} = 2.576 > z_{0.025} = 1.960\); that is, demanding more certainty comes at the cost of a less precise estimate.
- Wald vs. Wilson: when the condition \(n\hat{p} \geq 5\) and \(n(1-\hat{p}) \geq 5\) is met at both ends, the two methods usually give very similar results. If the proportion is extreme or the sample is small, Wilson is more reliable because the center of the interval shifts slightly toward less extreme values and the bounds always stay within \([0, 1]\).
- Connection with hypothesis testing: if a reference value \(p_0\) falls outside the interval, the data would reject \(H_0\!: p = p_0\) at level \(\alpha = 1 - C\) in the equivalent two-sided test. If \(p_0\) falls inside, there isn't enough evidence to reject it.
- Practical relevance: a very narrow CI indicates high precision, but remember that statistical precision and practical relevance are different concepts. An interval from 67% to 68% is very precise but could be irrelevant in contexts where only exceeding 70% matters.
Frequently asked questions
- Can I enter p̂ directly instead of x? Enter x = p̂ × n rounded to the nearest integer; the result will be equivalent.
- What happens if x = 0 or x = n? Wald gives an interval of zero width, which is not useful. Wilson handles these cases correctly.
- When is the normality condition met? When n·p̂ ≥ 5 and n·(1−p̂) ≥ 5. The calculator warns you if it isn't met.
Reference: Binomial proportion confidence interval — Wikipedia