Confidence Interval Calculator
Calculate confidence intervals for population parameters.
Related calculators
About
Confidence Interval Calculator
This calculator produces a confidence interval and margin of error for a sample mean. A sample of 50 with a mean of 20.6 and a standard deviation of 3.2 gives a 95% confidence interval of 20.6 ±0.887, or [19.713 – 21.487], which is a relative margin of ±4.3%. The step-by-step panel shows the Z value, the standard error, and how they combine.
What a confidence interval is
A confidence interval is a range of plausible values for something you cannot measure directly. You measured a sample; what you actually want to know is the population value behind it. The interval is your estimate plus a stated allowance for the fact that a different sample would have given a slightly different answer.
Two things set the width. The standard error, which is the standard deviation divided by the square root of the sample size, describes how much sample means bounce around. The confidence level decides how many standard errors either side of the mean you draw the boundary.
What "95% confident" actually means
This is the part almost everyone gets wrong, and it is worth being precise about. The confidence level describes the procedure, not the particular interval in front of you.
If you drew 100 samples and built a 95% interval from each, about 95 of those 100 intervals would contain the true population value. That is the guarantee. It says nothing about any single interval. Once you have computed one, it either contains the true value or it does not, and there is no probability left in the matter.
So "there is a 95% chance the true mean is between 19.713 and 21.487" is a misstatement, however natural it sounds. The defensible version is that the method producing this interval captures the true mean 95% of the time. In practice people act on the interval as though it brackets the answer, which is reasonable; it is the probability claim about this specific interval that does not hold up.
A second, separate misreading is worth heading off: the interval is not where 95% of your data sits. It is a range for the mean, and it is much narrower than the spread of individual values. The range that covers most individual observations is a prediction interval, which is a different calculation.
Three ways to write the same interval
The same result gets written in three formats, and they carry identical information:
- As a value plus a margin: 20.6 ±0.887
- As a value plus a relative margin: 20.6 ±4.3%
- As bounds: [19.713 – 21.487]
The relative form is the one to reach for when comparing measurements of different sizes, because a margin of ±0.887 means something very different on a mean of 20.6 than on a mean of 2,060.
The formula
For a mean where the standard deviation is known, the interval is the sample mean plus or minus Z times the standard error:
x̄ ± Z ×σ√n
Here x̄ is the sample mean, σ is the standard deviation, n is the sample size, and Z is the critical value for your confidence level. Working the default figures through: the standard error is 3.2 ÷ √50 = 0.452548, the Z value for 95% is 1.9600, and multiplying gives a margin of 0.887. Add and subtract that from 20.6 and you have the interval.
A second example with rounder numbers: a mean of 22.8 from a sample of 100 with a standard deviation of 2.7 gives a standard error of 0.27, and 1.9600 × 0.27 = 0.5292, so the interval is 22.8 ±0.5292.
Where the Z values come from
The Z value is the point on a standard normal distribution that leaves your chosen confidence level in the middle and splits the remainder between the two tails. At 95%, 5% is left over, 2.5% goes in each tail, and the cutoff is 1.9600.
The table on this page lists the common levels, from 1.036 at 70% up to 4.417 at 99.999%. Notice how the cost of certainty accelerates. Going from 90% to 95% raises Z from 1.645 to 1.960, about 19% wider. Going from 99% to 99.9% raises it from 2.576 to 3.291, and pushing to 99.999% widens it again by a third. Very high confidence is expensive in precision, which is why 95% became the default in most fields rather than anything higher.
When to use t instead of Z
This calculator uses the Z distribution, which assumes the standard deviation is known or the sample is large enough that the sample standard deviation is a reliable stand-in. That assumption is the one to check before trusting a narrow interval.
If the standard deviation came from the sample itself and the sample is small, the correct distribution is Student's t, with degrees of freedom of n minus 1. The t distribution has fatter tails, so it produces a wider interval, which is the honest response to not knowing the true spread.
The gap closes as the sample grows. At n = 50 the 95% t value is about 2.010 against a Z of 1.960, so the interval is roughly 2.5% wider, which rarely changes a decision. At n = 10 the t value is 2.262, about 15% wider, which might. Above roughly n = 30 the two are close enough that Z is the usual choice, and that is where the common "n greater than 30" rule of thumb comes from. Below that, and especially below 15, a Z interval understates your uncertainty.
What makes an interval narrower
Three levers exist, and only one of them is usually under your control.
Sample size is the main one, and it works through a square root, which makes it unforgiving. Halving the margin of error requires four times the data. On the default figures, going from 50 to 200 observations takes the margin from 0.887 to 0.443. Going from 50 to 500 gets you to 0.281. The diminishing return is why survey samples cluster around 1,000 people; the next meaningful improvement costs several thousand more.
The standard deviation is the second, and it is a property of what you are measuring rather than a knob you can turn. Cleaner measurement or a more homogeneous population reduces it. The Standard Deviation Calculator works it out from raw data.
The confidence level is the third, and lowering it narrows the interval without adding any information, which is why moving from 95% to 90% to make a result look tighter is a poor idea. If you want to work backwards from a target margin to the sample size you need, the Sample Size Calculator does that directly.
Assumptions worth checking
The formula rests on the sample mean being approximately normally distributed. The central limit theorem delivers that for most distributions once the sample is reasonably large, which is why it works even when the underlying data is not normal.
It breaks down in a few situations. Heavily skewed data or strong outliers need a larger sample before the theorem takes hold, sometimes far more than 30. Samples that are not random are the bigger problem, because no interval width can fix selection bias; a badly drawn sample of 10,000 is worse than a random sample of 300. If your sample is a large fraction of a small population, above roughly 5%, a finite population correction shrinks the interval, and this calculator does not apply one.
One more caution when comparing groups. Two confidence intervals that overlap slightly can still represent a statistically significant difference, so eyeballing overlap is not a substitute for a proper test. The Z-Score Calculator and the Statistics Calculator cover the related ground.
How this calculator works
It takes your confidence level, converts it to a two-tailed probability, and finds the matching Z value using an inverse normal function accurate to about one part in a billion, so the table figures match published values to three decimals. It divides your standard deviation by the square root of the sample size for the standard error, multiplies by Z for the margin, and reports the interval, the bounds, and the margin as a percentage of the mean.
Any confidence level between 0 and 100 works, including ones outside the table, so 97.5% or 99.7% are both fine. The error bar shows the interval to scale with the mean marked, which makes it easier to see how much of the width comes from the margin rather than reading the numbers alone.
Common questions
Frequently asked questions
Take the sample mean, then add and subtract Z times the standard error, where the standard error is the standard deviation divided by the square root of the sample size. For a mean of 20.6, a standard deviation of 3.2, and a sample of 50 at 95%, that is 20.6 ± 1.9600 × 0.452548, giving 20.6 ±0.887 or [19.713 – 21.487].
It means the method works 95% of the time, not that this interval has a 95% chance of being right. If you drew 100 samples and built an interval from each, about 95 would contain the true value. Once you have one specific interval, it either contains the true mean or it does not.
1.9600. It is the point on a standard normal distribution leaving 2.5% in each tail. Other common values are 1.645 for 90%, 2.326 for 98%, 2.576 for 99%, and 3.291 for 99.9%. The table on this page lists the full set.
It is the half-width of the interval, the ± part. It equals the Z value times the standard error, so 1.9600 × 0.452548 = 0.887 on the default figures. Quoted as a percentage of the mean it becomes the relative margin, ±4.3% here, which is the fairer way to compare measurements of different sizes.
Use t when the standard deviation came from the sample and the sample is small, with degrees of freedom of n minus 1. At n = 50 the 95% t value is about 2.010 against a Z of 1.960, only 2.5% wider. At n = 10 it is 2.262, around 15% wider. Above roughly n = 30 the difference rarely matters, which is where the common rule of thumb comes from.
Collect more data, since the margin shrinks with the square root of the sample size. Halving the margin needs four times the sample: going from 50 to 200 observations takes the margin from 0.887 to 0.443. Lowering the confidence level also narrows it, but that buys precision with no new information.
No, and this is a common mix-up. It is a range for the mean, and it is far narrower than the spread of individual values. The range covering most individual observations is a prediction interval, which is a different and much wider calculation.
When the sample is not random, since no width can correct selection bias. Also when the data is heavily skewed or has strong outliers and the sample is small, because the central limit theorem has not taken hold yet. If your sample is more than about 5% of a small population, a finite population correction would narrow the interval, and this calculator does not apply one.