When I took AP Statistics during my sophomore year, the class taught how to construct a confidence interval for a proportion using a normal approximation to a binomial distribution. It was also called a “z-interval”. I don’t like it because it uses an approximation which limits the versatility of the method.
The confidence interval is constructed as sample proportion (p̂ ) plus or minus the product of the critical value of the normal distribution and the sample standard deviation. The confidence interval is valid if it satisfies these three conditions:
- The sample data is from a randomized experiment in order to limit bias.
- The sample size (n) is 10% or less than the population size, in order to ensure independence.
- The amount of successes (np̂ ) and failures (n(1-p̂ )) are both greater than 10 so the sampling distribution is approximately normal. This condition is called Large Counts.
If all conditions are met, then one may proceed with the calculation:
The margin of error for a confidence interval is the critical value of the normal distribution multiplied by the sample standard deviation. The critical value for the normal distribution is approximately 1.96 for a 95% confidence interval. This implies that 95% of the normal distribution’s area is between -1.96 and 1.96 standard deviations away from the mean. The sample standard deviation is
Which is derived from the binomial distribution. Putting it all together, the confidence interval is:
This method for a confidence interval focuses on the amount of successes given a certain probability of success to form a binomial distribution, and then approximates the binomial distribution with a normal distribution. However, the amount of successes and failures must be large enough for the normal approximation to work. This is quite limiting for small experiments.
Let’s test the accuracy of using a normal distribution to approximate a binomial distribution with various probabilities of success and trial counts. The binomial distribution has a mean of np and a standard deviation of √np(1-p), so I will graph a normal distribution with these parameters for its mean and standard deviation over the binomial.
With a binomial distribution with n=100 and p=0.5, the normal distribution is a great fit for the binomial:

With n=20 and p=0.5, the normal distribution is still an okay fit. This is the smallest sample size which meets Large Counts for a z-interval.

When n=100 and p=0.1, the binomial distribution is a bit skewed, but still satisfies Large Counts. This is because Large Counts becomes less effective for a probability of success that is too low or high.

For n=20 and p=0.1, the normal distribution is not a good approximation at all. This is a huge problem for experiments with a small sample size.

What can we do to improve the confidence interval for a proportion?
Well, instead of focusing the calculations of the confidence interval on the number of successes of a binomial distribution for a given probability, what if we looked at which probabilities are most likely given a certain amount of successes? When we create a z-interval, we are assuming that we know what our probability is, and are creating hypothetical experiments based on this probability to test how it affects the data. Additionally, the binomial distribution is a discrete distribution, but we are using the continuous normal distribution to approximate it.
Doesn’t it seem unnatural to test hypothetical situations when we already have a certain one? Besides, we can’t be sure that the probability of success that we calculated is the true probability. Let’s try varying the probability of success for a binomial distribution and keeping the amount of successes constant. This is called the Bayesian prior, named after the statistician Thomas Bayes.
The probability mass function for a binomial distribution is:
Here’s an example graph with n=16 and p=0.25:

Let’s look at the probability of the random variable equaling exactly 6:
Now, let’s let p be the variable:
Let’s graph this function between 0 and 1.

This looks like a probability distribution, but the area under the curve is 1/17, not 1. A curve generated this way will always have an area of 1/(n+1). The shape of the curve is the exact same as another type of distribution:
The Beta Distribution
The beta distribution has the following probability density function (pdf):
The beta function B(a,b) is defined as:
This is the normalizing constant which makes the total area under the beta curve 1.
The reciprocal of this quantity is:
Comparing the two quantities, n=α+β-2 and x=α-1. Because n=16 and x=6 in our example, α=7 and β=11, and this is why the curve generated by the binomial distribution had an area of 1/(n+1) = 1/(α+β-1) = 1/17.
The cumulative density function (cdf) of the beta distribution uses the inverse beta function evaluated at x. This function adds up the area under the beta curve from 0 to x. It evaluates to 1 at x=1. The function is written as:
We can use this function to find the critical values for the confidence interval.
The Confidence Interval
To construct an accurate 95% confidence interval based off an actual scenario with p successes and q failures, we need to create an interval with the x-values which contain 95% of the area of the beta distribution with 2.5% on either tail as bounds. These are the values at the 2.5th and 97.5th percentile of the distribution. The interval can be expressed using the inverse beta function:
We can be exactly C% confident in an this interval. We will call this a beta-interval.
This procedure is extremely easy to calculate using the Beta Inverse function, which is included in Google Sheets, Excel, and several other math programs. It also doesn’t require a large sample size like the z-interval, although the interval will be large if the sample size is small. The sample size can even be zero (Although the 95% confidence interval will be [0.025,0.975] if it is). Needless to say, it still requires an unbiased and independent experiment.
Comparison:
Assume that over the course of 16 stops, each on a different day, the bus is late 6 times. (This situation mirrors the problem I used to derive the beta curve). What is the 95% confidence interval of the true proportion of days the bus will be late?
This doesn’t meet the Large Counts condition for the z-interval, but we will proceed anyway. The sample size is small, so the interval will be large either way.
The associated 95% confidence z-interval is:
The associated 95% confidence beta-interval is:
The beta-interval is over 5% more narrow than the z-interval, meaning that it’s more accurate and more precise. If AP Statistics taught this formula, statistics majors in college wouldn’t have to relearn as much of what they were taught in the AP course.

Leave a Reply