If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

# Confidence interval simulation

AP.STATS:
UNC‑4.F (LO)
,
UNC‑4.F.1 (EK)
,
UNC‑4.F.2 (EK)
,
UNC‑4.F.3 (EK)
,
VAR‑1 (EU)
,
VAR‑1.H (LO)
,
VAR‑1.H.1 (EK)

## Video transcript

the goal of this video is to use this scratch pad on Khan Academy that was written by Khan Academy's er Charlotte Allen in order to get a better intuitive sense of confidence intervals so we're here we're dealing with a gumball machine where a certain proportion of the gumballs are going to be green and so let's say we can set that on let's make that 60% of the gumballs are green but let's say someone else comes along and they don't actually know the proportion of gumballs that are green but they can take samples and so let's say they take samples of 50 at a time and so they draw a sample the sample proportion right over here actually just happened to be 0.6 but then they could draw another sample this time the sample proportion is 0.5 - or 52% of those 50 gumballs happened to be green now you could say all right well these are all different estimates but for any given estimate what how confident are we that the a certain range around that estimate actually contains the true population proportion and so if we look at this tab right over here that's what confidence intervals are good for and in a previous video we talked about how you calculate the confidence interval what we want to do is say well there's a 95% chance and we get that from this confidence level and 95% is the confidence level people typically use and so there's a 95% chance that whatever our sample proportion is that it's within two standard deviations of the true proportion or that the to purport that the true proportion is going to be contained in an interval that are two standard deviations on either side of our sample proportion well if you don't know the true proportion the way that you estimate the standard deviation is with the standard error which we've done in previous videos and so this is two standard errors to the right and two standard errors to the left of our sample proportion and our confidence interval is this entire interval going from this left point to this right point and as we draw more samples you can see it's not obvious but our intervals change depending on what our actual sample proportion is because we use our sample proportion to calculate our confidence interval because we're assuming whoever is doing the sampling does not actually know the true population proportion now what's interesting here about this simulation is that we can see what percentage of the time does our confidence interval does it actually contain the true parameter so let me just draw 25 samples at a time and so you can see here that's right now 93 93 percent of our for 93 percent of our samples did our confidence interval actually contain our population parameter and we can keep sampling over here and we can see the more samples that we take it really is approaching that close to 95 percent of the time our confidence interval does indeed contain the true parameter and so once again we did all that math in the previous video but here you can see that confidence intervals calculated the way that we've calculated them actually do a pretty good job of what they claim to do then if we calculate a confidence interval based on a confidence level of 95% that it is indeed the case that roughly 95% of the time the true parameter the population proportion will be contained in that interval and I could just draw more and more and more samples and we can actually see that happening every now and then for sure you get a sample where even when you calculate your confidence interval the true parameter the true population proportion is not contained but that is the exception that happens very infrequently 95% of the time your true population parameter is contained in that interval now another interesting thing to see is if we increase our sample size our confidence interval is going to get narrower so if we increase our sample size will just make it 200 now let's draw some samples notice now our confidence intervals are narrower but still because our confidence level which was used to calculate these intervals is still 95% when we draw a bunch of samples we are still going to get roughly 95% of the time our confidence intervals contain our true population proportion but 5 roughly 5% of the time they don't
AP® is a registered trademark of the College Board, which has not reviewed this resource.