Skip to content
All apps

Confidence interval

About this app

Repeated samples, stacked confidence intervals — the fraction that covers the true μ matches the confidence level. Against the misconception "95% probability that μ lies in the interval": the statement applies to the procedure, not to the single interval.

The statistics

A confidence interval gives a range that covers an unknown parameter such as the mean μ at a chosen confidence level. With known spread σ it is x̄ ± z·σ/√n, where z depends on the level (about 1.96 for 95 %). The level is a statement about the procedure: if you repeat the study very often, about 95 % of the intervals cover the true μ. It is not the probability that μ lies in one particular interval, because μ is fixed and the interval is random.

What you see

Each row is a sample from a normal distribution N(μ, σ) with its interval x̄ ± z·σ/√n. The intervals stack one below the other, and a vertical line marks the true μ. Intervals that cover μ and those that miss it are shown in different colours. A values panel lists μ, σ, n, the z value, the theoretical level and the actual coverage rate of the intervals on screen.

Things to try

Choose 95 % and draw new samples several times: usually about 2 of 40 intervals miss the true μ, sometimes more, sometimes fewer. Increase the number of samples and the coverage rate approaches the level. Set 99 %; the intervals get wider and misses become rarer. Then increase the sample size n and watch the intervals narrow with 1/√n while the coverage rate stays the same.

Frequently asked questions

What does a 95 % confidence interval mean?
It means that the procedure used to compute the interval would, over many repetitions, produce an interval containing the true parameter about 95 % of the time. Any single computed interval either contains μ or it does not. The 95 % refers to the method, not to the individual interval.
How do you calculate a confidence interval for a mean?
With a known standard deviation σ it is x̄ ± z·σ/√n, with z = 1.96 for 95 %. If σ is unknown and estimated from the sample, you use the sample standard deviation s and the quantile of the t distribution with n − 1 degrees of freedom. The term σ/√n is called the standard error.
How does the width of a confidence interval depend on n?
The width is proportional to 1/√n. To halve the interval you need four times the sample size. A higher confidence level makes the interval wider for the same n.
What can I set in the confidence interval app?
You choose the confidence level (80, 90, 95 or 99 %), the sample size n and the number of samples, and draw new samples. The app shows which intervals cover μ and compares the coverage rate with the theoretical level.

Subject: Statistics

More from Statistics

A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps