GARETH GRANTTECHNOLOGY · DATA · INNOVATION
Explore

16 / Inference

Confidence interval for a proportion: Wilson interval

A proportion confidence interval expresses uncertainty about a binary outcome rate. The Wilson interval is a score-based method that remains within 0–1 and is preferable to the simplest symmetric normal interval in many practical small-rate settings.

IntermediateLive exploration + Python

The business question

How uncertain is the defect, conversion or satisfaction rate estimated from a sample?

  • Report uncertainty around a defect, conversion or repeat-purchase percentage.
  • Avoid treating zero observed defects as proof that a process has a zero defect probability.
  • Judge whether a sample is precise enough for a rate-based operating requirement.

How the method works

Count successes x and their eligible denominator n using one consistent outcome rule. The observed rate x/n is an estimate, and its uncertainty depends on both the rate and denominator. Four percent from 200 inspected items provides different information from four percent from 20,000 items. Specify the population, sampling period and independence assumptions before choosing the interval.

The Wilson interval comes from inverting a score test for a binomial rate. It adjusts the centre and width rather than simply using observed rate ±1.96 times its plug-in standard error. This avoids impossible negative endpoints and the zero-width interval that the simplest method gives after zero successes. It is still an approximate frequentist method, with coverage properties that depend on the setting.

Interpret the interval as uncertainty about a stable population probability under the sampling model. It is not a range containing 95% of customer outcomes; those outcomes are individually zero or one. Compare its relevant bound with the practical requirement, and specify a one-sided or two-sided analysis in advance. Complex samples, correlated transactions or a changing process require more than the independent-binomial formula.

The calculation

Wilson centre = (p̂ + z²/(2n))/(1+z²/n); half-width = z sqrt(p̂(1−p̂)/n + z²/(4n²))/(1+z²/n)
Read the symbols
SymbolMeaning
p̂ = x/nObserved success proportion and its numerator/denominator.
nEligible independent trials in the basic binomial model.
zStandard normal critical value; about 1.96 for a 95% two-sided interval.
boundsAdjusted centre minus and plus the Wilson half-width.

A worked business example

ILLUSTRATIVE SCENARIO

Illustrative packaging inspection finds eight defective units among 200 randomly sampled units from a stable process. The manager asks whether the observed 4% rate establishes a defect probability below 5%.

Inputs

  • x = 8 defective units; n = 200 inspected units.
  • Observed rate p̂ = 8/200 = 0.04.
  • 95% two-sided Wilson confidence interval.

Work through the numbers

  1. Use z = 1.95996398, so the denominator adjustment is 1 + z²/200 = 1.0192073.
  2. Adjusted centre = (0.04 + z²/400)/1.0192073 ≈ 0.0486689.
  3. Compute the Wilson half-width using the stated formula, approximately 0.0282632.
  4. Endpoints are 0.0204056 and 0.0769321, or 2.04% and 7.69%.
Observed defect rate 4.00%; 95% Wilson interval approximately 2.04%–7.69%.

The sample is compatible with defect probabilities above 5%, so the observed 4% alone is not sufficient evidence for the proposed claim. A different planned one-sided requirement would need its corresponding analysis.

Explore the decision

Estimate a binary outcome rate. The live explorer has its own example inputs; it is separate from the worked calculation above.

Enable JavaScript to use this calculator. The worked example and executable Python remain available.

Apply it at work

  1. Define the binary outcome, eligible denominator and target population.
  2. Check the sampling design, duplicate units and stability of the event probability.
  3. Compute the chosen confidence interval and show the numerator and denominator beside the rate.
  4. Compare the appropriate planned bound with the business threshold, and collect more relevant data if precision is inadequate.

Check these assumptions

  • The basic Wilson calculation uses independent Bernoulli observations with a common p.
  • The sample is relevant to the rate being claimed and outcome labels are accurate.
  • The confidence level and whether the interval is one- or two-sided are chosen before inspecting the result.
  • Parameter uncertainty is addressed by the interval, but selection bias and misclassification are separate concerns.

Common mistakes and how to avoid them

  • Reporting a percentage without its denominator hides how much evidence supports it.
  • No observed defects still permits a positive underlying defect probability.
  • Switching to a one-sided interval after seeing a disappointing two-sided result changes the pre-planned question.

How this can help the business

  • Quality or conversion dashboards can convey evidence strength instead of presenting noisy rates as exact.
  • A company can decide whether an operating claim needs more data before it changes pricing, staffing or customer promises.
A decision rule to adapt

Use the pre-specified rate threshold and confidence bound, and separate an inconclusive result from evidence that the process meets or fails the requirement.

When to use another approach

Use an exact binomial interval, a beta posterior interval with disclosed prior assumptions, or a survey-design-adjusted interval when the sampling design requires it.

Reproduce the worked example in Python

The code is self-contained for this example. Dependencies and run instructions are included with the downloadable notebook.

Show executable code and recorded output
from scipy.stats import binomtest
defects, inspected = 8, 200
interval = binomtest(defects,inspected).proportion_ci(confidence_level=0.95,method='wilson')
print(f'Observed defect rate: {defects/inspected:.2%}')
print(f'95% Wilson interval: {interval.low:.2%} to {interval.high:.2%}')
print('Includes rates above 5%:', interval.high > 0.05)

Recorded output

Observed defect rate: 4.00%
95% Wilson interval: 2.04% to 7.69%
Includes rates above 5%: True
Download all worked examples

Sources and further reading

Concepts are linked to primary teaching or technical sources. The business examples are illustrative applications, not reported client results.