How Do Confidence Intervals Work?

This Demonstration shows the confidence interval, , for based on random samples of size from a normal population with mean and standard deviation , where is the sample mean and is the margin of error for a level interval. There are two cases, corresponding to when is assumed known, or is not known and is estimated by the standard deviation in the sample. For the known case, , where the critical value is determined so that the area to the right of is . Similarly in the unknown case, , where is the sample standard deviation and is the critical value determined from a -distribution with degrees of freedom.
Five things to see in this Demonstration:
1. The width of the confidence interval increases as increases.
2. The width of the confidence interval decreases as increases.
3. For fixed and , the width of the confidence interval in the known case is fixed, but it is stochastic when is unknown due to the variation in the sample standard deviation, . The stochastic property can be seen by varying the random seed when unknown is selected.
4. The width of the confidence interval tends to be larger in the unknown case but the difference decreases as increases.
5. Running an animation varying the random seed, we can obtain an empirical estimate of the coverage probability. Try slowing the animation down to get a large number of repetitions. The intervals are color coded: black when the interval covers and red when it misses. The animation demonstrates the stochastic coverage probability of the interval.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


If we assume that , the unknown mean, has a suitable noninformative prior, the confidence interval with level confidence is equivalent to the highest posterior density interval [1] p. 85 and p. 98, and we can make the natural statement that .
[1] G. E. P. Box and G. C. Tiao, Bayesian Inference in Statistical Analysis, Reading: Addison-Wesley, 1973.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2017 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+