Confidence intervals and margin of error | AP Statistics | Khan Academy
It is election season, and there is a runoff between Candidate A versus Candidate B. We are pollsters, and we're interested in figuring out, well, what's the likelihood that Candidate A wins this election? Well, ideally, we would go to the entire population of likely voters right over here. Let's say there's 100,000 likely voters, and we would ask every one of them, "Who do you support?" From that, we would be able to get the population proportion. This is the proportion that support Candidate A.
However, it might not be realistic—in fact, it definitely will not be realistic—to ask all 100,000 people. So instead, we do the thing that we tend to do in statistics: we sample this population and we calculate a statistic from that sample in order to estimate this parameter. Let's say we take a sample right over here. So, this sample size—let's say n equals 100—and we calculate the sample proportion that support Candidate A.
Out of the 100, let's say that 54 say that they're going to support Candidate A. So, the sample proportion here is 0.54. Just to appreciate that, we're not always going to get 0.54. There could have been a situation where we sampled a different 100, and we would have maybe gotten a different sample proportion. Maybe in that one, we got 0.58.
We already have the tools in statistics to think about this: the distribution of the possible sample proportions we could get. We've talked about it when we thought about sampling distributions. So, you could have the sampling distribution of the sample proportions, and it's going to—this distribution is going to be specific to what our sample size is for n equal to 100.
We can describe the possible sample proportions we could get and their likelihoods with this sampling distribution. So, let me do that. It would look something like this. Because our sample size is so much smaller than the population—it's way less than 10%—we can assume that each person we're asking is approximately independent. Also, if we make the assumption that the true proportion isn't too close to zero or too close to one, then we can say that, well, look, the sampling distribution is roughly going to be normal.
I have a normal, this kind of bell curve shape, and we know a lot about the sampling distribution of the sample proportions. For example, and if this is 4 and 2, I encourage you to watch the videos on this on KH Academy. The mean of this sampling distribution is going to be the actual population proportion. We also know what the standard deviation of this is going to be.
Let me—maybe that's one standard deviation. This is two standard deviations. That's three standard deviations above the mean. That's one standard deviation, two standard deviations, and three standard deviations below the mean. So, this distance—let me do this in a different color. This standard deviation right over here, which we denote as the standard deviation of the sample proportions for this sampling distribution.
We have already seen the formula, there, it's the square root of P * (1 - P) where P is once again our population proportion divided by our sample size. That's why it's specific for n equal to 100 here.
In this first scenario, let's just focus on this one right over here. When we took a sample size of n equal to 100 and we got the sample proportion of 0.54, we could have gotten all sorts of outcomes here. Maybe 0.54 is right over here. Maybe 0.54 is right over here.
The reason why I have this uncertainty is we actually don't know what the real population parameter is, what the real population proportion is. But let me ask you maybe a slightly easier question: What is the probability that our sample proportion of 0.54 is within two standard deviations of P? Pause the video and think about that.
Well, that's just saying, look, if I'm going to take a sample and calculate the sample proportion right over here, what's the probability that I'm within two standard deviations of the mean? That's essentially going to be this area right over here, and we know from studying normal curves that approximately 95% of the area is within two standard deviations.
So, this is approximately 95%—95% of the time that I take a sample size of 100 and I calculate this sample proportion, 95% of the time I'm going to be within two standard deviations. But if you take this statement, you can actually construct another statement that starts to feel a little bit more, I guess we could say, inferential.
We could say there is a 95% probability that the population proportion P is within two standard deviations of P-hat, which is equal to 0.54. Pause this video and appreciate that these two are equivalent statements. If there's a 95% chance that our sample proportion is within two standard deviations of the true proportion, well, that's equivalent to saying that there's a 95% chance that our true proportion is within two standard deviations of our sample proportion.
This is really, really interesting because if we were able to figure out what this value is, well then we would be able to create what you could call a confidence interval. Now, you immediately might be seeing a problem here. In order to calculate this, our standard deviation of this distribution, we have to know our population parameter.
So, pause this video and think about what we would do instead if we don't know what P is here. If we don't know our population proportion, do we have something that we could use as an estimate for our population proportion? Well, yes! We calculated P hat already. We calculated our sample proportion.
A new statistic that we could define is the standard error of our sample proportions, and we can define that as being equal to—since we don't know the population proportion, we're going to use a sample proportion, P hat * (1 - P hat), all of that over n. In this case, of course, n is 100, we do know that.
It actually turns out, I'm not going to prove it in this video, that this actually is an unbiased estimator for this right over here. So, this is going to be equal to 0.54 * 0.46 all of that over 100. So, we have the square root of (0.54 * 0.46) divided by 100.
If I round to the nearest hundred, it's going to be—actually, if I round to the nearest thousand, it's going to be approximately 0.05. So, another way to say all of these things is instead we don't know exactly this, but now we have an estimate for it. So, we can now say with 95% confidence—and that will often be known as our confidence level—right over here, with 95% confidence, between...
So, we'd want to go two standard errors below our sample proportion that we just happened to calculate. So, that would be 0.54 minus 2 times 0.05, so that would be 0.54 minus 0.10, which would be 0.44. And we'd also want to go two standard errors above the sample proportion, so that would be that plus 0.10, and that would yield 0.64 of voters supporting Candidate A.
So, this interval that we have right over here, from 0.44 to 0.64, this will be known as our confidence interval. This will change—not just in the starting point and the endpoint—but it will change; the actual length of our confidence interval will change depending on what sample proportion we happen to pick for that sample of 100.
A related idea to the confidence interval is this notion of margin of error. For this particular case, for this particular sample, our margin of error—because we care about 95% confidence—would be two standard errors. Hence, our margin of error here is two times our standard error, which is 0.1 or 0.10.
We're going one margin of error above our sample proportion right over here and one margin of error below our sample proportion right over here to define our confidence interval. As I mentioned, this margin of error is not going to be fixed every time we take a sample. Depending on what our sample proportion is, it's going to affect our margin of error because that is calculated essentially with the standard error.
Another interpretation of this is that the method that we used to get this interval right over here, the method that we used to get this confidence interval, when we use it over and over, it will produce intervals, and the intervals won't always be the same. It's going to be dependent on our sample proportion, but it will produce intervals which include the true proportion, which we might not know and often don't know. It'll include the true proportion 95% of the time.
I'll cover that intuition more in future videos. We'll see how the interval changes, how the margin of error changes. But when you do this calculation over and over again, 95% of the time, your true proportion is going to be contained in whatever interval you happen to calculate that time.
Now, another interesting question is, well, what if you wanted to tighten up the intervals? On average, how would you do that? Well, if you wanted to lower your margin of error, the best way to lower the margin of error is if you increase this denominator right over here. Increasing that denominator means increasing the sample size.
One thing that you will often see when people are talking about election coverage is, "Well, we need to sample more people in order to get a lower margin of error." But I'll leave you there, and I'll see you in future videos.