A confidence interval is a range of values that represent an estimate for an unknown population parameter. Confidence intervals often vary from sample to sample as they are calculated directly from observations. Some confidence intervals actually contain the true population parameter while some may not.
A confidence level gives the percentage of all samples that are expected to contain the population parameter. Common confidence levels that are used in statistics are 99%, 95% and 90%, which respectively correspond to a 99%, 95%, or 90% probability that the confidence interval contains the true population parameter.
To estimate a confidence interval for an unknown population parameter, such as the mean, an approximation for the population mean, μ, is carried out at first by using the sample mean, $\stackrel{\u02c6}{\mathrm{\μ}}$, as an estimator.
$\stackrel{\u02c6}{\mathrm{\mu}}$ = $\stackrel{\u203e}{X}\=\frac{1}{n}{\sum}_{i\=1}^{n}\mathrm{X\_\_i}$ .
When taking several samples, each sample can produce different values for the sample mean, but most of the sample means should be relatively close to one another. The endpoints for the confidence interval can be determined by considering that the sample mean from a normally distributed sample is normally distributed, with a standard error of:
Standard Error = $\frac{\mathrm{\σ}}{\sqrt{n}}$,
where σ is the standard deviation and n is the number of observations in our sample.
Then, standardizing the sample mean gives:
Z = $\frac{\stackrel{\u203e}{X}\mathrm{\μ}}{\frac{\mathrm{\sigma}}{\sqrt{n}}}$.
When standardizing the sample mean, $\stackrel{\u02c6}{\mathrm{\μ}}$, the mean, μ, is subtracted to center the sample mean, then divided by the standard error to scale the value. The resulting value is a socalled standard score, or zscore, Z, which corresponds to values in a standard normal distribution.
If there is a significance level of α = 0.05 (corresponding to a Confidence Level of 1  α = 95% ), it can be used to determine values for z and z which form the lower and upper endpoints for the confidence interval:
$P\left(z\le Z\le z\right)equals;1\mathrm{alpha;}equals;0.95$
The value z is derived from the cumulative normal distribution function, represented by $\mathrm{\Phi}$:
$\mathrm{\Φ}\left(z\right)equals;P\left(Z\le z\right)equals;1\frac{\mathrm{alpha;}}{2}$,
$zequals;{\mathrm{Phi;}}^{1}\left(\mathrm{Phi;}\left(z\right)\right)equals;{\mathrm{\Phi}}^{1}\left(0.975\right)equals;1.96$
Substituting this back into the above:
$P\left(z\le Z\le z\right)equals;1\mathrm{alpha;}equals;0.95$,
$P\left(1.96\le \frac{\stackrel{\u203e}{X}\mathrm{\mu}}{\frac{\mathrm{\sigma}}{\sqrt{n}}}\le 1.96\right)$,
$P\left(\stackrel{\u203e}{X}1.96\frac{\mathrm{\sigma}}{\sqrt{n}}\le \mathrm{mu;}\le \stackrel{\u203e}{X}plus;1.96\frac{\mathrm{\sigma}}{\sqrt{n}}\right)$.
From this, the endpoints can be determined:
Lower Endpoint = $\stackrel{\u203e}{X}1.96\frac{\mathrm{\sigma}}{\sqrt{n}}$,
Upper Endpoint = $\stackrel{\u203e}{X}\+1.96\frac{\mathrm{\sigma}}{\sqrt{n}}$.
Generalizing this, the mean confidence interval can be calculated in the following manner:
$P\left(\stackrel{\u203e}{X}{Z}_{\mathrm{alpha;}sol;2}\frac{\mathrm{sigma;}}{\sqrt{n}}\le \mathrm{mu;}\le \stackrel{\u203e}{X}plus;{Z}_{\mathrm{\alpha}sol;2}\frac{\mathrm{\sigma}}{\sqrt{n}}\right)$,
where α is the significance level, σ is the standard deviation, n is the sample size, and μ is the mean.
