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.

Every figuretap a card to copy its value

Interval at each confidence level

Confidence levels compared

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%.

Twenty horizontal 95% confidence intervals from twenty random samples of 30 drawn from a population with a true mean of 50, with the sample means marked; nineteen cross the true mean line and one, from 40.5 to 47.8, misses it; beside it the 95% t values for 1, 2, 5, 10, 20, 30 and 60 degrees of freedom, from 12.706 down to 2.000, and the z value of 1.960
Every sample gives a different interval; the 95% is a promise about how often the method succeeds, and here it caught the true mean 19 times out of 20.

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 n90%95%99%
26.31412.70663.657
32.9204.3039.925
52.1322.7764.604
101.8332.2623.250
151.7612.1452.977
201.7292.0932.861
251.7112.0642.797
301.6992.0452.756
501.6772.0102.680
1001.6601.9842.626
10001.6461.9622.581
z, very large1.6451.9602.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