# Confidence Intervals

March 29, 2018

Back to: Random Testing

When calculating the point estimate of a random variable—such as the mean value—it is possible to determine the probable error for the estimate. This can be accomplished by evaluating the confidence interval associated with the confidence level of the estimate.

The confidence interval and the confidence level work together. A higher confidence level requires a wider interval. Similarly, a lower confidence level results in a narrower interval.

### Calculating a Confidence Interval

When summing independent random variables, the mean values and variances are added. For example, when summing independent random variables A and B:

(1)

Equation 12

(2)

Equation 13

Equation 13 can be used to determine the standard deviation of the mean value (x) computed from *N* random variables (*x*) with a known standard deviation (*s** _{x}*). The sum of

*x*will have a variance of

*N*

*s*

_{x}^{2}and, therefore, a standard deviation of . Dividing the value by

*N*to compute the standard deviation of x gives us Equation 14.

(3)

Equation 14

#### Confidence Level

Equation 14 is used to determine the confidence interval of an estimated mean value assuming x is normally distributed. The confidence interval depends on the probability, or confidence level, of the interval. It is determined by the probability of the value being within a certain number of standard deviations (σ _{x}) from the true mean (*μ*). The confidence level is represented by the letter P in the image below.

In Figure 3.12, the confidence level is plotted as a function of z, which is the number of standard deviations from the true mean. Therefore, a confidence interval of ±σ _{x} has a confidence level of 68%. The 95% confidence interval is ±2σ _{x}, the 99.7% confidence interval is ±3σ _{x}, etc. Note from Equation 14 that →σ _{x} as *N*→∞.

The normal distribution is almost always assumed for the estimation of the mean value because of the central limit theorem. If we use the previous example of a mean value obtained from an average of four values, the standard deviation of the uniform distribution (-0.5, 0.5) is 0.144. Assuming a normal distribution, the 95% confidence interval would be ±0.288. In reality, the 95% confidence interval is 0.24.

### T-Distribution

Determining of the confidence interval is more complicated for mean and standard deviation values obtained from a small data sample. In this case, it is common to use t-distribution. T-distribution provides larger confidence intervals for the same confidence level due to increased uncertainty in the sample distribution.

For *N* > 3 samples, the variance of the sample mean is increased by a ratio of (*N* – 1) / (*N* – 3) compared to Equation 13. Figure 3.13 shows the modified number (*t*_{value}) of standard deviations σ _{x} used for the confidence interval for different confidence levels as a function of the number of samples used. The estimate for the true mean is:

(4)

Equation 15

For *N* > 50, the t-distribution converges to the normal distribution and Figure 3.13 can be used.

The statement of the confidence interval often omits the confidence level. In many cases, a confidence level of 95% is assumed and a confidence interval of approximately ± 2σ is used. This is true in many opinion polls when a ± percent margin of error is appended to the percentage results given. In surveys with *N* respondents, the standard deviation is assumed to be σ = 0.5/*N*^{1/2}, so a margin of error of ± 4% (with a confidence level of 95%) simply means that approximately *N* = 1/(0.04)^{2} = 625 people were surveyed (4% = 0.04 = 2σ = 1/* N*^{1/2}).