★ GUIDES · STATISTICS · HOW TO CALCULATE

How to Calculate a Confidence Interval: 95% CI, Step by Step

To calculate a confidence interval, take the sample mean, add and subtract the margin of error: mean 100, SD 15, n 25 at 95% gives [93.81, 106.19]. This guide works the calculation step by step, shows how the critical value and the standard error set the width, and explains the mistakes to avoid — and the confidence interval calculator page does the same calculation for your own numbers, with the critical value and the margin of error. The p-value calculator page is the P-VALUE — the significance of a test statistic — not the range a mean probably sits in; the z-score calculator page is the Z-SCORE — how many standard deviations one value is from the mean — not the interval for the mean itself; and the standard-deviation-calculator page is the SPREAD — how far the numbers sit from the mean — not how precisely the mean is known.

How to calculate a confidence interval, step by step

A confidence interval is the sample mean plus or minus a margin of error: the critical value from the t or z curve, times the standard error. To calculate a confidence interval, take your sample mean, find the critical value for your confidence level, work out the standard error from the standard deviation and the sample size, multiply them for the margin of error, and add and subtract it from the mean. On the defaults — mean 100, sample standard deviation 15, sample size 25, 95% confidence — the interval is [93.81, 106.19], because the critical value is 2.0639, the standard error is 3.00, and the margin of error is 6.19. Work it out in the confidence interval calculator.

The worked example: mean 100, SD 15, n 25, 95%

The worked example, line by line. Step 1 — the degrees of freedom: 25 − 1 = 24. Step 2 — the critical value: t(24, 0.975) = 2.0639, the point on the t curve that leaves 2.5% in each tail. Step 3 — the standard error: 15 ÷ √25 = 15 ÷ 5 = 3.00, the spread divided by the square root of the sample size. Step 4 — the margin of error: 2.0639 × 3.00 = 6.19, the critical value times the standard error. Step 5 — the lower limit: 100 − 6.19 = 93.81. Step 6 — the upper limit: 100 + 6.19 = 106.19. The interval is [93.81, 106.19]: the sample mean, plus and minus 6.19. The same six steps work for any sample: find the critical value, find the standard error, multiply them, and add and subtract.

What a confidence interval is

A confidence interval is a range built from a sample, and the confidence level is a property of the method that built it. A 95% interval means that if you repeated the sampling many times, about 95% of the intervals built this way would contain the true mean. It does not mean there is a 95% chance that this one interval contains it — the true mean is either inside [93.81, 106.19] or it is not — and it does not mean 95% of the data falls inside it, because the data spreads wider than the interval. The width is the precision: a narrow interval is a precise estimate, a wide one is an honest admission of how little the sample says.

Critical values: t and z

The critical value is the point on the t or z curve that cuts off the tails beyond your confidence level, and it is the first number to get right. Use the t-distribution when you have a sample standard deviation, with n minus 1 degrees of freedom: at 95% with 24 degrees of freedom the critical value is 2.0639. Use the z-distribution when the population standard deviation is known: at 95% the critical value is 1.9600. The t curve has fatter tails, so its critical value is always larger — and the gap is biggest for small samples: at n = 10 the t critical value is 2.2622 against z at 1.9600, while at n = 100 they are 1.9842 and 1.9600, nearly the same. Higher confidence needs a larger critical value: at 90% the t critical value is 1.7109, at 95% it is 2.0639, and at 99% it is 2.7969. Pick the curve that matches what you know: t for a sample standard deviation, z for a known one.

Standard error and margin of error

The standard error is the standard deviation over the square root of the sample size, and it is what makes a big sample worth having: at n = 25 the standard error is 3.00, and at n = 100 it is 1.50, because four times the sample halves the error. The margin of error is the critical value times the standard error — 2.0639 × 3.00 = 6.19 on the defaults — and it is the half-width of the interval, the distance from the mean to either end. Three things set it: a bigger sample shrinks it, a tighter spread shrinks it, and a higher confidence level widens it. More data narrows an interval faster than more confidence: doubling the sample cuts the error by about 30%, quadrupling it cuts it in half. A proportion works the same way, with a different standard error: the square root of p̂(1 − p̂) over n, so a proportion of 0.60 from 400 people has a standard error of 0.02 and a margin of error of 0.05.

What 95% does and does not mean

Ninety-five percent is the most quoted confidence level, and the most misunderstood. It does not mean 95% of the data falls in the interval — the data spreads from far below 93.81 to far above 106.19, because the interval is about the mean. It does not mean there is a 95% chance the true mean is inside this interval — the true mean is a fixed number, and it is either in or out. What 95% does mean is a trade: more confidence costs width, so a 99% interval of [91.61, 108.39] is wider than the 95% interval of [93.81, 106.19], and a 90% interval of [94.87, 105.13] is narrower. Report the interval itself, not just the confidence level, and the width tells the reader how much the sample actually says.

Common mistakes

The first is reading the interval as a range for the data — [93.81, 106.19] is where the mean probably sits, not where the observations sit. The second is using z with a sample standard deviation — z at 1.9600 is smaller than t at 2.0639, so the interval comes out narrower than it should be. The third is treating 95% as a probability about this interval — the confidence is a property of the method, not of the one interval in front of you. The fourth is confusing a narrow interval with a good sample — a narrow interval can come from a small spread or a big sample, and neither says the sample was random. The fifth is forgetting that the interval assumes a roughly normal mean — on a skewed distribution or a tiny sample the coverage is approximate, and a proportion near 0 or 1 needs a different interval. Work it out in the confidence interval calculator, and check the z-score calculator and the standard-deviation calculator before you decide what the answer means.

From a confidence interval back to a sample size

Sometimes the question runs the other way: how big a sample do I need for a margin of error of 5? On the defaults — a standard deviation of 15 at 95% — the smallest sample size is 38, where the margin of error is 4.93. A tighter target needs a bigger sample, and the cost grows fast — halving the margin of error needs four times the sample. The confidence interval calculator works those reverses out for any mean, spread and confidence level. Going backwards is the same calculation in reverse: pick the interval you want, and find the sample that gives it.

Frequently asked questions

How do I calculate a confidence interval?

Take the sample mean, add and subtract the margin of error: mean 100, SD 15, n 25 at 95% gives [93.81, 106.19]. Find the critical value for your confidence level, work out the standard error, multiply them for the margin of error, and add and subtract it from the mean. Put your own numbers into the confidence interval calculator and it works out the interval, the critical value and the margin of error.

What is the confidence interval formula?

CI = mean ± critical value × (SD / √n), where the critical value comes from the t curve for a sample standard deviation or the z curve for a known population standard deviation. On the defaults: 100 ± 2.0639 × (15 / √25) = 100 ± 6.19 = [93.81, 106.19]. The calculator above does it for any mean, spread, size and confidence level.

How do I find the critical value?

Read it off the t or z curve at your confidence level: t(24, 0.975) = 2.0639 for 95% with 24 degrees of freedom. The degrees of freedom are n minus 1 for a t interval. At 90% the t critical value is 1.7109, at 95% it is 2.0639, and at 99% it is 2.7969. The confidence interval calculator finds it for any confidence level and sample size.

What is the difference between a t and a z confidence interval?

Use t when you have a sample standard deviation and z when the population standard deviation is known. At n = 25 the t critical value is 2.0639 against z at 1.9600, so the t interval is wider. The gap is biggest for small samples — at n = 10, t is 2.2622 — and the two agree when the sample is large.

What does 95% confidence mean?

It means that if you repeated the sampling many times, about 95% of the intervals built this way would contain the true mean. It does not mean there is a 95% chance this one interval contains it, and it does not mean 95% of the data falls inside it. The interval on the defaults is [93.81, 106.19].

How big a sample do I need for a margin of error of 5?

On the defaults — a standard deviation of 15 at 95% — the smallest sample size is 38, where the margin of error is 4.93. Halving the margin of error needs four times the sample, because the standard error falls with the square root of n. The calculator's reverses list the sample size for each common target.