Confidence Interval Calculator
Build a confidence interval around a sample mean with the normal distribution: give the mean, the standard deviation and how many observations you have, pick a confidence level, and get the margin of error. The wider you want to be sure, the wider the interval.
This is the normal (z) interval. If the standard deviation was estimated from a small sample, the t distribution is the right curve and returns a slightly wider interval.
Formula and calculation
Worked example
A sample mean of 100 with a standard deviation of 15 from 30 observations has a standard error of 2.74. At 95% confidence the critical value is z = 1.96, so the margin of error is 5.37 and the interval runs from 94.63 to 105.37. The same sample at 99% confidence would reach further out, because more confidence costs more width.
How many samples do you need?
The margin of error shrinks with the square root of the sample size, which is why precision gets expensive fast. Doubling a sample of 100 cuts the margin by 29%; halving the interval — say from ±5 to ±2.5 — needs roughly four times the data. Rearranged for planning, the formula reads n = (z × σ ÷ margin)². If you do not have a standard deviation yet, estimate it from a pilot sample or take it from the standard deviation calculator, then check the resulting interval here. The same curve also powers the p-value calculator and the z-score calculator.
What the results mean
- Lower bound
- The lower end of the confidence interval — the smallest value for the true mean that is consistent with your sample at this confidence level. Read it together with the upper bound as one interval, not as two numbers.
- Upper bound
- The upper end of the interval. A 95% interval means the procedure captures the true mean in about 95% of samples like yours; it does not mean 95% of your data falls inside these bounds.
- Margin of error
- The margin of error: half the width of the interval. It shrinks with the square root of the sample size, so four times the data halves it — and doubling the data only cuts it by about 29%.
- Critical z
- How many standard errors the interval reaches out from the mean for this confidence level: 1.96 at 95%, 1.645 at 90%, 2.576 at 99%. It is the same number the two-tailed 5% cutoff uses in hypothesis testing.
- Standard error of the mean
- The standard error of the mean, σ ÷ √n: how precisely the sample mean pins down the population mean. The margin of error is this number multiplied by the critical z.
- Margin at twice the sample size
- The margin of error you would get from twice as many observations with the same spread. Doubling the sample cuts the margin by about 29%, the factor 1 − 1 ÷ √2.
Frequently asked questions
How do you calculate a confidence interval?
Multiply the critical z for your confidence level by the standard error (σ ÷ √n), then add and subtract that product from the sample mean. At 95% the critical z is 1.96: a mean of 100 with a standard error of 2.74 gives a margin of 5.37, or an interval from 94.63 to 105.37.
Should I use z or t for a confidence interval?
Use z when the population standard deviation is known or the sample is large. When you estimated the standard deviation from the same sample — the common case — the t distribution is technically correct, and the gap matters for small samples: at 95% with 10 observations the multiplier is 2.26, not 1.96. Treat this calculator's interval as slightly optimistic in that situation.
What does a 95% confidence interval actually mean?
It means the method captures the true mean in about 95 of every 100 samples. A single interval either contains the truth or it does not; the confidence belongs to the procedure, not to the one interval in front of you — which is why saying “there is a 95% chance the true mean is in here” is a common but sloppy shortcut.
Why does doubling the sample size not halve the margin of error?
Because the margin depends on 1 ÷ √n rather than 1 ÷ n. Doubling n divides it by √2, about 29%. Halving the margin needs four times the sample, and making it ten times tighter needs a hundred times the sample.
Can the margin of error be bigger than the mean?
Yes, and it is worth paying attention to: a mean of 5 with a margin of 8 gives an interval from −3 to 13, which usually means the sample is too small or the spread too wide to say anything useful yet. Add more observations and the interval narrows.