AP subjects/AP Statistics/Confidence Interval Simulator
CED 3.3AP Statistics

Confidence Interval Simulator

Use this free confidence interval simulator to build hundreds of intervals for a population proportion and count how many capture the true value. It shows what "95% confident" really means: a statement about the long-run success rate of the method, not about any one interval.

Controls
d1d200d50npreset

How to use the simulator

Set up the population and the procedure:
  • True proportion (p): 0.05 to 0.95 in steps of 0.01, starting at 0.50. In real life this is unknown; here you choose it so you can see which intervals catch it.
  • Sample size (n): 20 to 500 in steps of 5, starting at 100.
  • Confidence level buttons: 90% (z* = 1.645), 95% (z* = 1.960, the default) and 99% (z* = 2.576).
Then build intervals with Draw 1, Draw 50 or Draw 200, and clear them with Reset. Changing p, n or the confidence level also clears everything, so every interval on screen comes from the same procedure.
Each draw takes a random sample, computes its p^\hat{p}, and builds the interval p^±z∗p^(1−p^)/n\hat{p} \pm z^*\sqrt{\hat{p}(1-\hat{p})/n}, just as you would with real data. On the plot each interval is a horizontal bar on a 0 to 1 axis, with a small circle at p^\hat{p} when the rows are tall enough. A dashed vertical line marks the true p. Teal bars capture it; coral bars miss. The newest interval is on top and up to 120 are shown, but the counters include every interval.
The three counters show Intervals, the number captured and the number missed, each with its percentage to one decimal.
With p = 0.50 and n = 100 at 95%, several rounds of Draw 200 give capture rates that hover near 95%. Switch to 99% and the bars get wider and miss less often. Now try p = 0.05 and n = 20, where the expected number of successes is only 1. Even at 95%, the capture rate settles far below 95% (around 64% in the long run), because the Large Counts condition fails and the formula breaks down.

The formula

A one-sample z-interval for a population proportion:
p^±z∗p^(1−p^)n\hat{p} \pm z^* \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}
  • p^\hat{p} is the sample proportion, the point estimate.
  • p^(1−p^)/n\sqrt{\hat{p}(1-\hat{p})/n} is the standard error of p^\hat{p}. It uses p^\hat{p} because pp is unknown.
  • z∗z^* is the critical value: 1.645 for 90%, 1.960 for 95%, 2.576 for 99%.
  • The margin of error is z∗×SEz^* \times \text{SE}, half the width of the interval.
Conditions: a random sample; n≤10%n \le 10\% of the population when sampling without replacement; and Large Counts, at least 10 successes and 10 failures in the sample (np^≥10n\hat{p} \ge 10 and n(1−p^)≥10n(1-\hat{p}) \ge 10).
Width moves in two ways. A higher confidence level means a larger z∗z^* and a wider interval. A larger nn shrinks the standard error by n\sqrt{n}, so four times the sample size halves the margin of error.

Worked example

Problem: In a random sample of 400 students at a large university, 248 support a later start to classes. Construct and interpret a 95% confidence interval for the proportion of all students at the university who support it.
Step 1: Check conditions. The sample is random. 400 is less than 10% of the students at a large university. There are 248 successes and 152 failures, both at least 10.
Step 2: Point estimate and SE. p^=248/400=0.62\hat{p} = 248/400 = 0.62. SE=0.62(0.38)400≈0.0243\text{SE} = \sqrt{\dfrac{0.62(0.38)}{400}} \approx 0.0243.
Step 3: Margin of error. 1.96×0.0243≈0.04761.96 \times 0.0243 \approx 0.0476.
Step 4: Interval. 0.62±0.04760.62 \pm 0.0476 gives (0.572,0.668)(0.572, 0.668).
Step 5: Interpret. We are 95% confident that the interval from 0.572 to 0.668 captures the true proportion of all students at this university who support a later start. With the same data, a 90% interval is (0.580,0.660)(0.580, 0.660) and a 99% interval is (0.557,0.683)(0.557, 0.683).
Check it in the simulator: set p to 0.62 and n to 400 at 95%. Each interval is about 0.095 wide, like yours. Draw 200 a few times: roughly 95 in every 100 intervals are teal. Your one real interval is like one of those bars; you cannot tell whether it is teal.

Common mistakes on the AP exam

  • "There is a 95% probability that p is in this interval." Once computed, the interval either contains pp or it does not. The 95% describes the method: about 95% of intervals built this way capture pp.
  • "95% of students are in this interval." The interval estimates one parameter. It says nothing about where individual values fall.
  • Checking Large Counts with pp. In an interval pp is unknown, so use the observed successes and failures, np^n\hat{p} and n(1−p^)n(1-\hat{p}).
  • Thinking more confidence means more precision. Moving from 95% to 99% widens the interval. Only a larger sample buys both.
  • Interpreting without context. Name the parameter: "the true proportion of all students at this university who support a later start," not "the proportion."
  • Using the wrong z∗z^*. 1.96 belongs to 95% only. Match the critical value to the stated level.

When the AP exam uses this

Confidence intervals for a proportion are topic 3.3, and the general form, statistic ± (critical value)(standard error of statistic), is on the AP Statistics formula sheet. Free-response questions often ask for the full process (conditions, calculation and interpretation in context) or for an interpretation of the confidence level itself.
Embed this simulator on your class page

Free for classroom use. Paste this into your site, LMS page or blog; keep the credit link under it.