Mathematics
Confidence interval calculator
Mean, standard deviation and number of observations: the interval appears at once, with the curve and a simulation of twenty samples showing what 95% really means.
How to read a confidence interval
A 95% confidence interval is built by a method that, repeated over many samples, contains the true population mean 95% of the time. The simulation above shows it: each row is a different sample and, usually, one in twenty misses.
Its width depends on three things: how variable the data are, measured by the standard deviation; how many observations there are, because the standard error is σ/√n; and the confidence level, since asking for more certainty widens the interval. Halving the margin of error takes four times the observations.
Example: 40 students with a mean height of 172.5 cm and a standard deviation of 7.2 cm. The standard error is 7.2/√40 ≈ 1.14 cm, the t value for 39 degrees of freedom is about 2.02, and the 95% interval runs from about 170.2 to 174.8 cm.
Common mistakes
- Saying there is a 95% probability that the mean lies in the computed interval: the mean is fixed, it is the interval that varies from sample to sample.
- Using z with small samples and an estimated standard deviation: the interval comes out too narrow.
- Thinking 95% of observations fall inside the interval: it is about the mean, not individual values.
Frequently asked questions
What is the difference between 95% and 99%?
At 99% the interval is wider: to be surer of capturing the mean you accept a less precise interval.
How many observations do I need?
The margin of error shrinks as 1/√n: for a margin E you need about (z·σ/E)² observations.
When should I use Student's t?
Whenever the standard deviation is computed from the same data, which is nearly always. Beyond a hundred or so observations t and z give practically the same result.
How this calculation works
Interval = x̄ ± c · s/√n, where c is the 1 − (1 − level)/2 quantile of the normal (z) or of Student's t with n − 1 degrees of freedom. The simulation draws samples of n values from a normal distribution and rebuilds the interval each time with the same method.
Related calculators
Descriptive statistics
Mean, median, mode, standard deviation, quartiles and frequency distribution.
P-value
The p-value of a z or t test, one- or two-tailed, with the area drawn under the curve and the decision on H₀.
Probability
Classical and conditional probability, Bayes and the binomial distribution.