Misc: Understanding the Wilson's Confidence Interval


The logic behind the Wilson formula

Not a hypothesis test — no null hypothesis, no p-value. Just where the two endpoints of a Wilson confidence interval come from.

  1. You observed \( x \) successes out of \( n \), so \( \widehat{p} = x/n \). That is the ★ star on the axis below.
  2. Pick a candidate value for the true proportion \( p \), and build a prediction interval around it: $$p \pm z \sqrt{\frac{p(1-p)}{n}}$$ The standard error uses the candidate \( p \), not \( \widehat{p} \).
  3. Check whether the star falls inside that interval. If it does, this \( p \) is plausible.
  4. Do this for every \( p \). The plausible ones are the confidence interval, so only its two extremes matter: the candidates whose interval only just reaches the star. Those are the endpoints — and the only two drawn below.

Use the two sliders below to find them.


Your task

Move each slider until its prediction interval turns green.

  • RED — the interval does not reach the star. This candidate is implausible, so it sits outside the confidence interval.
  • YELLOW — the interval covers the star, but not at its end. Plausible, so inside the confidence interval — but not an endpoint.
  • GREEN — the interval only just reaches the star, which sits exactly on its end. This is an endpoint.

Each slider has exactly one green position. Work in from the red end. When both are green, a box appears below.

Your data

The example above already works — only change these if you want to try numbers of your own.

Error: \( x \) must be a whole number strictly between 0 and \( n \). At \( x = 0 \) or \( x = n \) the sample proportion sits on a boundary, one endpoint collapses onto it, and there is nothing left to line up. Kept the previous value.

Error: \( n \) must be a whole number of at least 2. Kept the previous value.

Error: the confidence level must be between 1 and 99 percent. Kept the previous value.


The ★ is your observed \( \widehat{p} \). Each curve is the distribution of the sample proportion under one candidate \( p \) (its dashed tick on the axis marks the candidate); the shaded part and the bar along the axis are that candidate's prediction interval. A prediction interval can extend past 0 or 1 — that is the normal approximation showing its limits, and it does not affect the endpoints you are looking for.


Candidate to the LEFT of the star

Aim its upper limit at the star.

012345 678910
Candidate to the RIGHT of the star

Aim its lower limit at the star.

012345 678910