Confidence Interval Calculator
Confidence Interval Calculator
Find the confidence interval for an average from its mean, standard deviation and sample size, straight from a list of numbers, or for a percentage from a count of successes. Uses the t distribution for small samples and the Wilson interval for proportions, with the working shown.
Interval at each confidence level
Average: mean ± t × s ÷ √n, with t from the Student t distribution with n − 1 degrees of freedom, or z from the normal curve when the population standard deviation is known. Proportion: the Wilson score interval, (p + z² ÷ 2n ± z × √(p(1 − p) ÷ n + z² ÷ 4n²)) ÷ (1 + z² ÷ n), with the simpler Wald interval p ± z × √(p(1 − p) ÷ n) shown for comparison. Assumes a random sample; for an average from a small sample, the data should be roughly normal. The CSV, image and printed report contain the values you entered, nothing preloaded.
How to use this tool
Choose what the interval is for. For an average, enter the sample mean, the standard deviation and the number of values, or paste the numbers themselves and the calculator works out the mean and standard deviation. For a proportion, such as the share of customers who said yes, enter the number of successes and the sample size. Pick a confidence level and the interval appears with its margin of error, a chart of how it widens with confidence and a table of every level.
The setting people most often get wrong is the standard deviation. Leave it on “from the sample” unless you know the population value from long experience; that uses the t distribution, which is correct for real data and matters most for small samples. Make sure the standard deviation is the sample value, calculated with n − 1, not the standard error.
What the calculation is doing
A sample mean varies from one sample to the next. Its typical error is the standard error, s ÷ √n, which falls as the sample grows. A confidence interval takes the mean and extends it by a multiple of the standard error on each side, and the multiple is chosen so that the method captures the true mean at the stated rate, 95 times in 100 for a 95% interval.
For large samples the multiple comes from the normal curve: 1.96 for 95%. For small samples, the standard deviation itself is uncertain, so William Gosset’s t distribution is used instead, with heavier tails and a larger multiple: 2.262 for 10 values, 2.045 for 30. For a proportion the same idea applies with a standard error of √(p(1 − p) ÷ n), refined by the Wilson method so that it behaves well near 0 and 100%.

Why t, and why Wilson
With a small sample the standard deviation you calculate can be well off the true value, and more often too small than too large. If you used the normal 1.96 anyway, your 95% intervals would miss more than 5% of the time. The t distribution corrects for that by widening the interval, a lot for very small samples and hardly at all past a few dozen values. With 5 values the 95% multiplier is 2.776; with 100 it is 1.984.
For proportions, the familiar Wald interval, p ± 1.96 × √(p(1 − p) ÷ n), is taught everywhere but performs badly when n is small or p is near 0 or 1. Zero successes out of 20 gives a Wald interval of 0% to 0%, which claims certainty the data cannot support. The Wilson interval for the same data is 0% to 16.1%, a far more honest answer. For moderate proportions and large samples the two agree closely.
Both methods assume a random sample. For an average from a small sample the data should also be roughly bell shaped; strong skew or outliers can distort the interval. Plot the data if you can, and with very skewed data consider a larger sample or a transformation.
t values by sample size
The multiplier applied to the standard error for each sample size and confidence level, with n − 1 degrees of freedom.
| Sample size n | 90% | 95% | 99% |
|---|---|---|---|
| 2 | 6.314 | 12.706 | 63.657 |
| 3 | 2.920 | 4.303 | 9.925 |
| 5 | 2.132 | 2.776 | 4.604 |
| 10 | 1.833 | 2.262 | 3.250 |
| 15 | 1.761 | 2.145 | 2.977 |
| 20 | 1.729 | 2.093 | 2.861 |
| 25 | 1.711 | 2.064 | 2.797 |
| 30 | 1.699 | 2.045 | 2.756 |
| 50 | 1.677 | 2.010 | 2.680 |
| 100 | 1.660 | 1.984 | 2.626 |
| 1000 | 1.646 | 1.962 | 2.581 |
| z, very large | 1.645 | 1.960 | 2.576 |
A worked example you can check on paper
The NIST/SEMATECH handbook uses 195 measurements with a mean of 9.261460 and a standard deviation of 0.022789. The standard error is 0.022789 ÷ √195 = 0.0016320. With 194 degrees of freedom the 95% t value is 1.9723, so the margin is 1.9723 × 0.0016320 = 0.0032187, and the interval is 9.258241 to 9.264679. The handbook, which rounds t to 1.9723 before multiplying, gives 9.258242 to 9.264679.
For a proportion: 45 successes out of 100. p = 0.45 and z = 1.96. The Wald interval is 0.45 ± 1.96 × √(0.45 × 0.55 ÷ 100) = 0.45 ± 0.0975, or 35.2% to 54.8%. The Wilson centre is (0.45 + 1.96² ÷ 200) ÷ (1 + 1.96² ÷ 100) = 0.4518, and its interval is 35.6% to 54.8%.
Mistakes that catch people out
Using the standard error as the standard deviation. Entering s ÷ √n where s is expected divides by √n twice and gives an interval far too narrow.
Using z for a small sample. With 10 values, z understates the width by about 13%. Use t unless the population standard deviation is truly known.
Reading the interval as a range for individual values. A confidence interval is for the mean or the proportion. Individual values scatter much more widely; that needs a prediction or tolerance interval.
Saying there is a 95% chance the true value is inside. The 95% belongs to the method across repeated samples, not to one computed interval.
Ignoring how the sample was drawn. The interval covers random sampling error only. A biased sample can give a tight interval around the wrong value.
Popular calculations
Each opens the calculator with those values filled in, and they can be changed once it is open. Intervals are at 95% confidence unless stated.
Mean from summary statistics
Other confidence levels and known sigma
Proportions, Wilson interval
From raw data
How this was checked
The t critical values are computed from the Student t distribution through the incomplete beta function and match the NIST/SEMATECH handbook table: 12.706, 4.303, 2.571, 2.262, 2.228, 2.086, 2.045, 2.042, 2.000 and 1.984 for 1, 2, 5, 9, 10, 20, 29, 30, 60 and 100 degrees of freedom at 95%, and 3.250 and 2.756 at 99% for 9 and 29. The handbook’s worked interval for 195 measurements was reproduced, and the Wilson interval was checked against published values such as 35.6% to 54.8% for 45 of 100.
Every address in the lists above was then opened and checked for a distinct title, the right interval, a chart that renders, and clean CSV, image and print output containing only the values entered, at desktop, tablet and phone widths.
Common questions
How do you calculate a confidence interval for a mean?
Take the mean and add and subtract t × s ÷ √n, where s is the sample standard deviation, n the sample size and t the value from the Student t distribution for your confidence level and n − 1 degrees of freedom. For a mean of 50, s = 10 and n = 30 at 95%, t = 2.045, so the interval is 50 ± 3.73, or 46.27 to 53.73.
When should I use t instead of z?
Use t whenever the standard deviation comes from the sample itself, which is almost always. Use z only if the population standard deviation is known in advance, for example from a long running process. For samples over about 30 the two are close: t is 2.045 for 30 values against z of 1.960.
How do you calculate a confidence interval for a proportion?
The simple Wald interval is p ± z × √(p(1 − p) ÷ n). It is easy but can be poor for small samples or proportions near 0 or 100%, and can even fall outside that range. The Wilson score interval fixes this by centring slightly toward 50% and is the one this calculator reports; for 45 out of 100 at 95% it gives 35.6% to 54.8%.
What does a 95% confidence interval mean?
That the method works 95% of the time: across many repeated samples, 95% of the intervals built this way would contain the true value. For any one interval the true value is either inside it or not; the 95% describes the procedure, not a probability about that single interval.
Why does a higher confidence level give a wider interval?
To be more certain of catching the true value you have to cast a wider net. At 95% the multiplier is 1.96 for large samples; at 99% it is 2.576, so the interval is about 31% wider. A bigger sample is the only way to get both high confidence and a narrow interval.
How do I make the interval narrower?
Collect more data. The width shrinks with the square root of the sample size, so four times the sample halves the width. Reducing the variability of the measurement, for example with a more precise instrument, also helps.
Related Calculators and Reference
- Sample Size Calculator: plan how much data you need for the width you want.
- Standard Deviation Calculator: the sample standard deviation to feed into the interval.
- Z Score Calculator: normal curve areas behind the z critical values.
- Weighted Average Calculator: a mean when some values count for more than others.
- Percentage Calculator: turn counts into the proportions the interval is built on.
- T Test Calculator: turn the interval into a hypothesis test.
- Linear Regression Calculator: confidence and prediction intervals for a fitted line.
- Bayes Theorem Calculator: how to update a probability when new evidence arrives, as in screening tests and other yes or no results.
- P Value Calculator: the p value and critical value behind a two tailed interval.
- NIST/SEMATECH Handbook: Confidence Limits for the Mean: the method and the worked example used to check this tool.
