Confidence Interval Calculator
Ten loaves averaging 800.5 g with a standard deviation of 8.0726 give a 95 percent interval of 794.73 to 806.27 g. The work is 2.2622 × 8.0726 ÷ 3.1623 = 5.7748 g of margin, using t at 9 degrees of freedom instead of 1.96.
Get a confidence interval for a mean from raw values or from a summary, for a share from a count, or work out the sample size you need before collecting anything. Means use the t distribution, so small samples get the wider interval they deserve.
| Interval | |
| Estimate | |
| Standard error | |
| Critical value | |
| Margin of error | |
| Second opinion |
All calculations run in your browser, and nothing you type is uploaded or stored.
Enter measurements, a summary, or a count of successes to get the interval at 90, 95 or 99 percent, with the t critical value and the sample size a chosen margin would need. All in the browser.
Key takeaways
- The interval is the estimate plus or minus a critical value times the standard error
- Use t, not 1.96, when the spread comes from your sample: 2.2622 at 9 degrees of freedom against 1.9600
- A share of 180 in 900 is 20 percent with a 95 percent interval of 17.39 to 22.61 percent
- A 3 point margin at 95 percent confidence needs 1068 responses if the share is near 50 percent
- Four times the sample halves the width, so each extra digit of precision costs a lot
On this page
- What the interval claims, in plain words
- A mean interval from ten numbers
- Why t replaces z when the spread comes from the sample
- A share needs a different interval
- Choosing a sample size before you collect
- One sided limits and other shapes
- Assumptions that break the arithmetic
- Reading two intervals side by side
What the interval claims, in plain words
A confidence interval is a range built so that, if the same study were repeated many times, about 95 percent of the ranges produced would contain the true value. This bread example gives an interval of 794.73 to 806.27 g around a mean of 800.5 g. The claim is about the method, not about these particular numbers: there is no 95 percent probability that the true mean sits inside this one range, because the true mean is a fixed number and the range either contains it or does not.
NIST states the same reading in its handbook on confidence limits for the mean: in the long run about 95 percent of such intervals would contain the true mean. That sentence is the whole idea, and it is the one most often misquoted.
What the interval is good for is scale. A target of 805 g sits inside this interval, so the ten loaves are consistent with that target. A target of 815 g sits outside it, so either the target is wrong or the process drifted. The width is the part that says how much evidence the sample carries, and it is driven by the spread of the data and the square root of the sample size.
The mechanics of that width, standard error and its behaviour as n grows, are on the standard error calculator. This page stays with the interval itself: how to build one for a mean or a share, how many observations it needs, and when the arithmetic stops being trustworthy.
A mean interval from ten numbers
Ten loaves came off a line and weighed 802, 795, 810, 788, 799, 805, 791, 807, 796 and 812 g. They add to 8005, so the mean is 800.5 g. The deviations from that mean add to zero, which is a useful check, and their squares add to 586.5.
| Loaf | Weight (g) | Deviation from 800.5 | Deviation squared |
|---|---|---|---|
| 1 | 802 | +1.5 | 2.25 |
| 2 | 795 | -5.5 | 30.25 |
| 3 | 810 | +9.5 | 90.25 |
| 4 | 788 | -12.5 | 156.25 |
| 5 | 799 | -1.5 | 2.25 |
| 6 | 805 | +4.5 | 20.25 |
| 7 | 791 | -9.5 | 90.25 |
| 8 | 807 | +6.5 | 42.25 |
| 9 | 796 | -4.5 | 20.25 |
| 10 | 812 | +11.5 | 132.25 |
| Total | 8005 | 0 | 586.5 |
Divide 586.5 by 9 degrees of freedom and the sample variance is 65.1667, so the sample standard deviation is 8.0726 g. The standard error of the mean is 8.0726 ÷ 3.1623 = 2.5528 g. For 95 percent confidence with 9 degrees of freedom the t value is 2.2622, so the margin is 2.2622 × 2.5528 = 5.7748 g and the interval runs from 794.73 to 806.27 g.
Two checks keep the answer honest. The interval should be centred on the estimate: 800.5 − 5.7748 and 800.5 + 5.7748 match the printed ends. And the interval should be much narrower than the spread of the raw values, which here run from 788 to 812: averaging ten loaves cancels most of the noise but not all of it.
If only the summary numbers are available, the same three inputs do the job. A supplier reports a mean of 500.0 ml with a standard deviation of 6.0 ml from 25 bottles, so the standard error is 1.2 ml, the t value at 24 degrees of freedom is 2.0639, and the interval is 497.52 to 502.48 ml.
Why t replaces z when the spread comes from the sample
The textbook interval uses 1.96 for a 95 percent interval, and that number belongs to the normal curve. It applies when the population standard deviation is known in advance, which in practice means almost never. When the spread is estimated from the same sample that supplies the mean, the estimate itself carries error, and the t distribution widens the interval to account for it.
| Degrees of freedom | 90 percent | 95 percent | 99 percent |
|---|---|---|---|
| 5 | 2.0150 | 2.5706 | 4.0321 |
| 9 | 1.8331 | 2.2622 | 3.2498 |
| 15 | 1.7531 | 2.1314 | 2.9467 |
| 30 | 1.6973 | 2.0423 | 2.7500 |
| 60 | 1.6706 | 2.0003 | 2.6603 |
| 120 | 1.6577 | 1.9799 | 2.6174 |
| normal curve, z | 1.6449 | 1.9600 | 2.5758 |
Read the 95 percent column downward and the correction has a clear shape. At 5 degrees of freedom the value is 2.5706, which makes the interval 31 percent wider than a z interval. At 30 degrees of freedom the gap is 4 percent, and by 120 degrees of freedom it is 1 percent. With the bread data the t value of 2.2622 gives an interval of 794.73 to 806.27, while z would give 795.50 to 805.50, a difference of about half a gram at each end.
That half gram is why the t correction is worth keeping even for small samples. It is the difference between claiming precision you have not earned and quoting what the data supports. For the share interval below, the normal curve is used instead, because a proportion's standard error does not depend on an estimated spread in the same way.
A share needs a different interval
For a yes or no question the estimate is a proportion, and its standard error is the square root of p times 1 minus p, divided by the sample size. A survey of 900 adults with 180 yes answers gives p = 0.20, a standard error of 0.01333, and a 95 percent margin of 1.96 × 0.01333 = 0.02613. The interval is 17.39 to 22.61 percent.
That interval is symmetric around 20 percent, which is a problem near the ends of the scale. At p = 0.02 the same formula produces a lower limit below zero, which cannot be a proportion. The Wilson interval replaces the symmetry with a formula that stays inside 0 and 1: it adds half the squared critical value to the successes and to the sample size before dividing. For the 180 of 900 case the Wilson interval is 17.52 to 22.74 percent, slightly shifted upward, and the shift grows as the share approaches 0 or 100 percent.
The normal approximation also needs enough of both outcomes. The usual rule is at least 10 successes and 10 failures, which the 180 and 720 split clears easily. A sample with 4 yes answers out of 30 does not, and there the Wilson interval or an exact method is the only honest option.
One more caution applies to any survey interval. The formula assumes a random sample of independent people. A volunteer panel, a website poll or a clustered sample of households has a design effect above 1, often between 1.5 and 2, and the real margin is wider by the square root of that factor.
Choosing a sample size before you collect
Planning runs the formula backwards. For a share, the margin of error is the critical value times the square root of p times 1 minus p over n, so n is the squared critical value times p times 1 minus p, divided by the squared margin. The unknown is p, and the safe choice is 0.5, which makes the product as large as it can be. For a 3 point margin at 95 percent confidence that gives 1.96 squared times 0.25 divided by 0.03 squared, which is 1068 people.
Assuming a share near 20 percent instead of 50 percent drops the same calculation to 683 people, a 36 percent saving. That assumption is a gamble: if the true share turns out to be 30 percent, the margin lands between the two figures and the study is underpowered for the precision it promised.
For a mean, the size depends on the standard deviation: n is the squared critical value times the variance, divided by the squared margin. With the bread standard deviation of 8.0726 g and a target of 2 g, the z formula gives 63 loaves. Because the critical value at 62 degrees of freedom is 1.9989 rather than 1.96, one iteration lifts the answer to 66. The widget does that iteration for you and reports both numbers.
| Target margin | Share near 50 percent | Share near 20 percent | Mean with s = 8.07 |
|---|---|---|---|
| 5 points, or 5 g | 385 | 246 | 13 |
| 4 points, or 4 g | 601 | 385 | 19 |
| 3 points, or 3 g | 1068 | 683 | 31 |
| 2 points, or 2 g | 2401 | 1537 | 66 |
The last column is worth a second look. Halving a 4 g margin to 2 g takes the sample from 19 loaves to 66, a factor of 3.5, because the effort scales with the square of the precision. That is the number to quote when someone asks for the interval to be twice as tight.
One sided limits and other shapes
Not every question needs two limits. A safety test asks only whether a value is below a threshold, and a quality check asks only whether it is above one. A one sided 95 percent bound uses the critical value for a 95 percent tail rather than a 97.5 percent tail, so z is 1.6449 instead of 1.9600 and t at 9 degrees of freedom is 1.8331 instead of 2.2622. The resulting interval is about 16 percent narrower for the same data and the same confidence.
Other quantities need other formulas. A median has no simple interval, and the bootstrap, which resamples the data thousands of times and takes percentiles of the results, is the standard fallback. A count or a rate follows a Poisson model, where the interval is built around the square root of the count. A difference between two means has its own standard error, and the interval for the difference is what a two sample test is reporting in practice.
A finite population correction applies when the sample is a large slice of a small population: multiply the standard error by the square root of N minus n over N minus 1. Sampling 250 of 500 invoices gives a factor of 0.708, which shrinks the interval by nearly 30 percent.
Bootstrapping also answers a question the formulas cannot: what happens when the statistic is not a mean. Percentile intervals from 10,000 resamples agree closely with the t interval for the bread data, which is a good sign, and diverge sharply for a heavily skewed quantity such as income, where the t interval is too narrow on the high side.
Assumptions that break the arithmetic
Four assumptions sit under every interval on this page, and each one has a visible symptom when it fails.
Independence comes first. Ten loaves from one batch share a mixer, an oven and a shift, so they are less independent than ten loaves from ten batches. When observations cluster, the effective sample size is smaller than the count, and the interval is too narrow. A design effect of 2 doubles the variance, and the width grows by 1.414.
Random selection comes second. A sample of volunteers is not a random sample, no matter how large it gets, and the 1068 person calculation above says nothing about the bias of a self selected panel.
Shape comes third. The t interval assumes the sample mean is close to normally distributed, which the central limit theorem delivers for moderate samples unless the data are badly skewed or have extreme outliers. The central limit theorem calculator shows how fast that convergence happens for different shapes. With 10 observations from a skewed distribution, the interval can be off by a wide margin even though the arithmetic is perfect.
Measurement rounding comes fourth, and it is easy to miss. If loaf weights are rounded to the nearest gram, each value carries up to 0.5 g of rounding error, which adds roughly 0.08 g squared to the variance. That is small against a variance of 65, but rounding to the nearest 10 g would matter, and a page that reports four decimal places from one decimal place data is claiming precision it does not have.
Reading two intervals side by side
Comparing two groups by eye is where intervals get misused. Two 95 percent intervals can overlap while the difference between the means is still clearly not zero, because the error of a difference grows with the square root of the sum of two variances, which is 1.41 times one error rather than twice it.
A concrete case: group A has a mean of 74.0 with an interval of 73.0 to 75.0, and group B has a mean of 71.8 with an interval of 70.8 to 72.8. The two intervals overlap between 72.8 and 73.0, which looks like no difference, yet the gap of 2.2 points has a standard error of 0.707 and a 95 percent interval of 0.81 to 3.59 points that excludes zero. Reading overlap as a verdict throws away a real difference.
The right move is to build the interval for the difference directly. Subtract one mean from the other, combine the standard errors in quadrature, and use the Welch degrees of freedom. A difference of 3.5 points with a standard error of 1.0998 and a t value of 2.0281 gives a margin of 2.23, so the interval for the gap runs from 1.27 to 5.73 points and excludes zero.
The CDC Field Epidemiology Manual describes a 95 percent interval in the same practical terms, as the range of values consistent with the data, and notes that an interval excluding the null value carries the same information as a significance test. That equivalence is the reason to report the interval rather than a bare p value.
The same logic applies to a change over time: an interval for the change is more informative than two intervals for the two readings, because it removes the shared variation that both readings carry.
Frequently asked questions
What is a 95 percent confidence interval in simple terms?
It is a range built by a method that captures the true value in 95 percent of repeated studies. For ten loaves weighing 800.5 g on average, the interval is 794.73 to 806.27 g. It is not a 95 percent chance that this particular range contains the truth.
How do I calculate a confidence interval for a mean?
Take the mean, add and subtract t times the standard deviation divided by the square root of n. For the loaves, 2.2622 × 8.0726 ÷ 3.1623 = 5.7748, so the interval is 800.5 plus or minus 5.7748 g.
When do I use t instead of 1.96?
Use t whenever the standard deviation comes from your own sample. With 9 degrees of freedom the 95 percent value is 2.2622, which is 15 percent wider than 1.96. The gap falls below 1 percent once the sample passes about 120.
What sample size gives a 3 percent margin of error?
1068 people for a share near 50 percent at 95 percent confidence, from 1.96 squared times 0.25 divided by 0.03 squared. A share near 20 percent needs only 683.
Why does a bigger sample make the interval narrower?
Because the standard error falls with the square root of the sample size. Going from 100 to 400 responses cuts the width of a 20 percent share interval from 15.68 to 7.84 points, and reaching 3600 responses brings it to 2.61 points.
What is the Wilson interval?
A proportion interval that stays between 0 and 100 percent and behaves better near the ends. For 180 of 900 it gives 17.52 to 22.74 percent, against 17.39 to 22.61 percent from the normal approximation.
Can a confidence interval include zero?
For a difference or a change, yes, and that is meaningful: an interval for a gap that runs from -1.2 to 4.8 points is consistent with no effect. For a mean weight in grams, zero is just a value that may or may not be inside.
What is the difference between a confidence interval and a prediction interval?
A confidence interval covers the mean. A prediction interval covers a single future observation and is much wider, because it adds the spread of individual values to the uncertainty of the mean. For the loaves, the prediction interval runs roughly from 781 to 820 g.
Does the interval have to be symmetric?
Only when the formula is built that way. The t interval for a mean is symmetric around the estimate. The Wilson interval for a share is not, and intervals from a bootstrap can be asymmetric in either direction.
What if my data are skewed?
The t interval still works for the mean if the sample is large enough for the central limit theorem to bite, roughly 30 or more observations for moderate skew. With 10 observations from a skewed distribution, use a bootstrap interval or report the median with its own interval.
How many observations do I need for a mean interval?
It depends on the spread and the margin you want. With a standard deviation of 8.07 and a target of 2 g, 66 loaves are enough; a target of 1 g needs 253, because precision costs the square of the improvement.
Why is my software's interval different from this one?
Common causes are a z value where t belongs, a different confidence level, or a finite population correction. Software that uses the population standard deviation with n in the denominator also gets a slightly narrower interval than one using n minus 1.
What is a 99 percent interval?
The same formula with a larger critical value: 3.2498 at 9 degrees of freedom against 2.2622 for 95 percent. For the loaves that widens the interval from 5.77 g to 8.29 g of margin, and it is wider because a 99 percent method misses less often.
Can I use a confidence interval with 5 observations?
Yes, with care. The t value at 4 degrees of freedom is 2.7764, so the interval is wide, which is the honest reflection of how little the sample says. Check for outliers as well, since one bad reading moves the mean and the spread at that size.
What does a confidence level of 90 percent mean?
The method captures the true value in 90 percent of repeated samples, so it misses twice as often as a 95 percent method. The interval is about 19 percent narrower: at 9 degrees of freedom the multiplier falls from 2.2622 to 1.8331.
Spotted a wrong number or a broken result?
More Math tools
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.