Confidence interval coverage simulator

Here you get to know the true proportion, which no real study ever does. Set it, draw samples, and count how many of the intervals actually contain it. That count is the only thing 95% confidence has ever meant.

intervals 0captured p 0missed 0observed rate n/anominal 95%

z* = 1.960 · exact long-run coverage of this interval at n = 50, p = 0.60: 94.1% · np = 30, n(1 - p) = 20 (both at least 10)

no intervals yet · blue = captures p · red diamond = misses

moving p or n re-runs every interval at the new setting

The true proportion is fixed at p = 0.60 and marked by the vertical line. Each sample of 50 produces one interval, drawn as a horizontal segment. The claim behind 95% confidence is about the procedure: in the long run, 95% of those segments should cross the line. Draw one, then draw 200.

Try to: draw at least 200 intervals catch an interval that misses p after 100 draws, land within 1 point of nominal

What to try

  1. One interval first. Press draw 1 sample. That interval either contains p or it does not, and you can see which. There is no 95% about a single interval, which is why saying there is a 95% chance p lies in your interval is the classic error.
  2. Then 200. Now the percentage means something. Around 5 or 6 in every 100 segments miss the line, and the ones that miss are not broken samples: they are the share the method openly budgets for.
  3. Change the level, not the data. Switch 95 to 99 after drawing. The same samples produce wider intervals and fewer misses. Confidence is bought with width, and that is the entire trade.
  4. Break it. Set n to 20 and p to 0.90. The observed rate drops into the high 80s against a nominal 95%, and the readout confirms the exact coverage is 87.6%. This is not a bug in the simulator; it is what the interval really does when np and n(1 - p) are small, and it is the reason you check for at least 10 successes and 10 failures.

Each sample is n Bernoulli trials summed into a count, and each interval is p-hat plus or minus z* times the square root of p-hat(1 - p-hat)/n. Moving p or n re-runs the whole simulation from the same seed at the new setting, so the picture is reproducible rather than a fresh accident each time.

For the wording that survives a scoring rubric, read what 95% confidence actually means. The arithmetic is in how to calculate a confidence interval and the confidence interval calculator, and the condition this page keeps breaking is explained in why you need 10 successes and 10 failures.

Embed this interactive on your class site (free)

Paste this into any webpage, LMS page, or class site. Free for educational use; the small credit link stays on.

Every interactive on the site is embeddable the same way. See the rest, with notes on where each one fits a lesson, on the resources for teachers page.