Confidence Interval Calculator
Build a confidence interval for a mean (z or Student t, from summary stats or raw data) or a proportion (Wilson and Wald), with the margin of error and every step.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the Confidence Interval Calculator?
A confidence interval turns a sample estimate into a range of plausible values for the population. This calculator builds one for a mean or for a proportion at any common confidence level from 80% to 99.9%. For a mean you can type the sample mean, standard deviation and size, or paste the raw values and let it work them out; for a proportion you type the number of successes and the sample size.
For means it uses the Student t distribution when the standard deviation comes from the sample, which is nearly always, and the z (normal) interval when the population σ is genuinely known. For proportions it shows the Wilson score interval, which is the one to report, next to the textbook Wald interval, and warns when the Wald version is unreliable. A shaded t or normal curve shows the critical value that sets the width.
- Mean intervals with Student t or z
- Proportion intervals by Wilson score and Wald, with a small-count warning
- Summary statistics or raw data input
- Accurate t quantiles for any degrees of freedom
- Shaded t or normal curve at the critical value
- Step-by-step working, copy and share
How to use the Confidence Interval Calculator
- Choose Mean or Proportion and pick the confidence level.
- For a mean, say whether the standard deviation comes from the sample (t) or is a known population σ (z), then enter summary statistics or paste the raw data.
- For a proportion, enter the number of successes (for example yes answers) and the sample size.
- Read the interval and margin of error at the top, and the critical value and standard error beside them.
- Check the steps in How this was calculated, then copy the result or share the link.
Worked examples
Mean from summary statistics
Input
x̄ = 50, s = 8, n = 25, 95%, t
Output
46.69776 to 53.30224 (50 ± 3.302238), t* = 2.063899 with 24 df
A z interval would give ± 3.135942, about 5% narrower, which understates the uncertainty when s is estimated from 25 values.
Mean from raw measurements
Input
12.1, 11.8, 12.6, 12.0, 12.4, 11.7, 12.3, 12.2 at 95%
Output
Mean 12.1375, s = 0.302076, interval 11.884958 to 12.390042
With only 8 values the t critical value is 2.364624 (df 7), noticeably larger than 1.96.
Known σ (z interval)
Input
x̄ = 100, σ = 15, n = 36, 95%, z
Output
95.10009 to 104.89991, margin ± 4.89991
Standard error 15 / 6 = 2.5, times 1.959964.
A small proportion
Input
2 successes out of 40, 95%
Output
Wilson 1.38% to 16.50%; Wald 0% to 11.75%
The Wald interval is symmetric around 5% and runs into zero, so it is cut off there. Wilson is asymmetric, as it should be near a boundary, and its upper limit is higher.
Background and insight
Every interval here has the form estimate ± critical value x standard error. For a mean the standard error is s / √n and the critical value is t with n - 1 degrees of freedom. The t distribution has heavier tails than the normal to allow for the extra uncertainty of estimating σ from the same data, so with 5 observations the 95% critical value is 2.776 rather than 1.960. The t quantile is computed by inverting the t CDF, which in turn comes from the regularised incomplete beta function; the tests check it against standard t-table values such as 12.706 (df 1), 2.228 (df 10) and 2.042 (df 30).
For a proportion the Wald interval, p̂ ± z√(p̂(1 - p̂)/n), is simple but behaves badly. Brown, Cai and DasGupta (2001) showed that its true coverage can fall far below 95% even for moderately large samples, and it collapses to a zero-width interval when there are no successes or no failures. The Wilson score interval, introduced by Edwin Wilson in 1927, inverts the score test instead. Its centre is pulled slightly toward 50%, it never goes below 0 or above 1, and its coverage stays close to the nominal level, which is why Agresti and Coull and most modern texts recommend it. The tests reproduce Newcombe's 1998 published examples, such as 81 out of 263 giving a Wilson 95% interval of 25.53% to 36.62%.
The interpretation is about the method, not the single interval: if you repeated the sampling many times, 95% of the intervals built this way would contain the true value. It does not mean there is a 95% chance this particular interval contains it, and it covers random sampling error only, not bias from how the sample was collected.
Common use cases
Reporting survey results
Give a poll result as 31% (95% CI 25.5% to 36.6%) instead of a bare percentage.
Lab and engineering measurements
State the mean of repeated measurements with an interval that reflects how many runs you did.
A/B tests and conversion rates
See how uncertain a conversion rate is before comparing two variants.
Coursework
Check a hand-built t or z interval and the critical value you looked up in a table.
Tips and limitations
- Use t unless σ is known from long experience or a specification. With an estimated s, a z interval is too narrow.
- The t interval assumes the mean is roughly normally distributed. With small samples, check that the data are not badly skewed.
- For proportions, report Wilson. The Wald interval is shown because many textbooks still teach it.
- Halving the margin of error takes four times the sample. The Sample Size Calculator works this out in advance.
- Overlapping intervals for two groups do not prove there is no difference; compare them with a proper two-sample test.
Frequently asked questions
How do you calculate a 95% confidence interval?
Take the estimate and add and subtract the critical value times the standard error. For a mean with a sample standard deviation that is x̄ ± t* x s / √n, where t* comes from the t distribution with n - 1 degrees of freedom (2.064 for n = 25).
When should I use t instead of z for a confidence interval?
Use t whenever the standard deviation is estimated from the sample. Use z only when the population standard deviation is known in advance. For large samples the two are almost identical, so t is never the wrong choice.
Why is the Wilson interval better than Wald for proportions?
The Wald interval often covers the true proportion less than its stated 95% of the time, especially with small samples or proportions near 0% or 100%, and it gives a zero-width interval when there are no successes. Wilson keeps close to the stated coverage and stays inside 0 to 1.
What does a 95% confidence interval actually mean?
If you repeated the study many times and built an interval each time, about 95% of those intervals would contain the true value. It is a statement about the procedure, not a 95% probability for one particular interval.
What is the margin of error in a confidence interval?
It is the half-width of the interval: the critical value times the standard error. A poll reporting 52% ± 3% has a margin of error of 3 percentage points.
Why does a higher confidence level give a wider interval?
To be right more often the interval has to cover more possibilities. At 99% the z critical value is 2.576 instead of 1.960, so the interval is about 31% wider than at 95% for the same data.
Is there an in-depth guide to the Confidence Interval Calculator?
Yes. “Confidence Intervals and Sample Size, Worked Through” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
Related Tools You May Like
Free, in-browser tools that pair well with this one.