Confidence Interval Calculator
A confidence interval for a mean is the sample mean plus or minus a margin of error: x̄ ± t* × s ÷ √n. For a sample of 25 with a mean of 50 and a standard deviation of 8, the 95% confidence interval is 46.6978 to 53.3022: the standard error is 1.6, the critical value t* (24 degrees of freedom) is 2.0639, and the margin of error is 3.3022. Enter your own mean, standard deviation and sample size (the calculator uses z instead of t when you tell it σ is known), paste a list of numbers, or switch to a proportion for the Wald and Wilson score intervals. The working is shown step by step below the result.
Updated Runs in your browser: nothing you enter is uploadedHow this tool works
x̄ ± t* × s/√n = 50 ± 2.0639 × 8/√25
95% CI: 46.6978 to 53.3022
With 95% confidence the population mean is between 46.6978 and 53.3022: the sample mean 50 plus or minus a margin of error of 3.3022 (t interval, 24 degrees of freedom).
- Confidence interval
- 46.6978 to 53.3022
- Lower limit
- 46.6978
- Upper limit
- 53.3022
- Margin of error (E)
- 3.3022
- Standard error (SE)
- 1.6
- Critical value (t*)
- 2.0639
- Degrees of freedom
- 24
- Sample mean (x̄)
- 50
- Sample standard deviation (s)
- 8
- Sample size (n)
- 25
- Confidence level
- 95%
Working
- Standard error: SE = s ÷ √n = 8 ÷ √25 = 1.6.
- Critical value: t* for 95% confidence with n − 1 = 24 degrees of freedom leaves 0.025 in each tail, so t* = 2.0639.
- Margin of error: E = t* × SE = 2.0639 × 1.6 = 3.3022.
- Interval: x̄ ± E = 50 ± 3.3022 = 46.6978 to 53.3022.
Critical t-values by degrees of freedom, with z* in the last row
| Degrees of freedom (df = n − 1) | 90% confidence | 95% confidence | 99% confidence |
|---|---|---|---|
| 1 | 6.314 | 12.706 | 63.657 |
| 2 | 2.920 | 4.303 | 9.925 |
| 3 | 2.353 | 3.182 | 5.841 |
| 4 | 2.132 | 2.776 | 4.604 |
| 5 | 2.015 | 2.571 | 4.032 |
| 10 | 1.812 | 2.228 | 3.169 |
| 15 | 1.753 | 2.131 | 2.947 |
| 20 | 1.725 | 2.086 | 2.845 |
| 24 | 1.711 | 2.064 | 2.797 |
| 30 | 1.697 | 2.042 | 2.750 |
| 60 | 1.671 | 2.000 | 2.660 |
| 120 | 1.658 | 1.980 | 2.617 |
| ∞ (z*) | 1.645 | 1.960 | 2.576 |
Critical z-values for common confidence levels
| Confidence level | Tail area each side | Two-sided z* |
|---|---|---|
| 80% | 0.1 | 1.282 |
| 90% | 0.05 | 1.645 |
| 95% | 0.025 | 1.960 |
| 98% | 0.01 | 2.326 |
| 99% | 0.005 | 2.576 |
| 99.9% | 0.0005 | 3.291 |
How the interval for a mean narrows as the sample grows (mean 50, s 8, 95% confidence)
| Sample size n | Degrees of freedom | t* | Standard error | Margin of error | Interval |
|---|---|---|---|---|---|
| 5 | 4 | 2.7764 | 3.5777 | 9.9333 | 40.0667 to 59.9333 |
| 10 | 9 | 2.2622 | 2.5298 | 5.7229 | 44.2771 to 55.7229 |
| 15 | 14 | 2.1448 | 2.0656 | 4.4303 | 45.5697 to 54.4303 |
| 25 | 24 | 2.0639 | 1.6 | 3.3022 | 46.6978 to 53.3022 |
| 30 | 29 | 2.0452 | 1.4606 | 2.9872 | 47.0128 to 52.9872 |
| 50 | 49 | 2.0096 | 1.1314 | 2.2736 | 47.7264 to 52.2736 |
| 100 | 99 | 1.9842 | 0.8 | 1.5874 | 48.4126 to 51.5874 |
| 400 | 399 | 1.9659 | 0.4 | 0.7864 | 49.2136 to 50.7864 |
The same sample at different confidence levels (n 25, mean 50, s 8)
| Confidence level | t* | z* | Margin of error (t) | t interval | z interval (σ known) |
|---|---|---|---|---|---|
| 80% | 1.3178 | 1.2816 | 2.1085 | 47.8915 to 52.1085 | 47.9495 to 52.0505 |
| 90% | 1.7109 | 1.6449 | 2.7374 | 47.2626 to 52.7374 | 47.3682 to 52.6318 |
| 95% | 2.0639 | 1.96 | 3.3022 | 46.6978 to 53.3022 | 46.8641 to 53.1359 |
| 98% | 2.4922 | 2.3263 | 3.9875 | 46.0125 to 53.9875 | 46.2778 to 53.7222 |
| 99% | 2.7969 | 2.5758 | 4.4751 | 45.5249 to 54.4751 | 45.8787 to 54.1213 |
| 99.9% | 3.7454 | 3.2905 | 5.9926 | 44.0074 to 55.9926 | 44.7352 to 55.2648 |
Sample size needed for a wanted margin of error when σ is 8
| Wanted margin of error E | 90% confidence | 95% confidence | 99% confidence |
|---|---|---|---|
| 0.5 | 693 | 984 | 1699 |
| 1 | 174 | 246 | 425 |
| 2 | 44 | 62 | 107 |
| 3 | 20 | 28 | 48 |
| 4 | 11 | 16 | 27 |
| 5 | 7 | 10 | 17 |
Wilson and Wald intervals for a proportion at 95% confidence
| Successes | Trials | Sample proportion | Wilson score interval | Wald interval |
|---|---|---|---|---|
| 0 | 20 | 0 (0%) | 0 to 0.1611 (0% to 16.11%) | 0 to 0 (0% to 0%) |
| 1 | 20 | 0.05 (5%) | 0.008881 to 0.2361 (0.89% to 23.61%) | 0 to 0.1455 (0% to 14.55%) |
| 5 | 20 | 0.25 (25%) | 0.1119 to 0.4687 (11.19% to 46.87%) | 0.0602 to 0.4398 (6.02% to 43.98%) |
| 10 | 20 | 0.5 (50%) | 0.2993 to 0.7007 (29.93% to 70.07%) | 0.2809 to 0.7191 (28.09% to 71.91%) |
| 18 | 50 | 0.36 (36%) | 0.2414 to 0.4986 (24.14% to 49.86%) | 0.227 to 0.493 (22.7% to 49.3%) |
| 45 | 120 | 0.375 (37.5%) | 0.2935 to 0.4642 (29.35% to 46.42%) | 0.2884 to 0.4616 (28.84% to 46.16%) |
| 95 | 100 | 0.95 (95%) | 0.8882 to 0.9785 (88.82% to 97.85%) | 0.9073 to 0.9927 (90.73% to 99.27%) |
| 20 | 20 | 1 (100%) | 0.8389 to 1 (83.89% to 100%) | 1 to 1 (100% to 100%) |
Margin of error of a poll result near 50% by sample size
| Sample size n | Margin of error | Interval around 50% |
|---|---|---|
| 100 | ±9.8% | 40.2% to 59.8% |
| 200 | ±6.93% | 43.07% to 56.93% |
| 400 | ±4.9% | 45.1% to 54.9% |
| 600 | ±4% | 46% to 54% |
| 1000 | ±3.1% | 46.9% to 53.1% |
| 1500 | ±2.53% | 47.47% to 52.53% |
| 2000 | ±2.19% | 47.81% to 52.19% |
| 4000 | ±1.55% | 48.45% to 51.55% |
Worked examples of the confidence interval for a mean
| Mean | Standard deviation | Sample size | Level | Standard error | t* | Margin of error | Confidence interval |
|---|---|---|---|---|---|---|---|
| 50 | 8 | 25 | 95% | 1.6 | 2.0639 | 3.3022 | 46.6978 to 53.3022 |
| 100 | 15 | 36 | 90% | 2.5 | 1.6896 | 4.2239 | 95.7761 to 104.2239 |
| 72.5 | 6.2 | 16 | 99% | 1.55 | 2.9467 | 4.5674 | 67.9326 to 77.0674 |
| 5.4 | 1.1 | 100 | 95% | 0.11 | 1.9842 | 0.2183 | 5.1817 to 5.6183 |
| 250 | 40 | 9 | 95% | 13.3333 | 2.306 | 30.7467 | 219.2533 to 280.7467 |
| 3.2 | 0.8 | 12 | 99% | 0.2309 | 3.1058 | 0.7173 | 2.4827 to 3.9173 |
| 1200 | 150 | 400 | 95% | 7.5 | 1.9659 | 14.7445 | 1185.2555 to 1214.7445 |
How to find a confidence interval for a mean
- Gather the sample statistics. You need the sample mean x̄, the standard deviation (s from the sample, or σ if it is known) and the sample size n: 50, 8 and 25 in the example. For a list of numbers, paste it in and the calculator works out x̄ and s.
- Work out the standard error. SE = s ÷ √n = 8 ÷ √25 = 1.6. It measures how much the sample mean typically varies from sample to sample.
- Look up the critical value. For 95% confidence with 24 degrees of freedom, t* = 2.0639. If σ is known, use the normal z* instead (1.96 for 95%).
- Multiply to get the margin of error. E = t* × SE = 2.0639 × 1.6 = 3.3022.
- Add and subtract it from the mean. 50 − 3.3022 = 46.6978 and 50 + 3.3022 = 53.3022, so the 95% confidence interval is 46.6978 to 53.3022.
Frequently asked questions
- What is a confidence interval?
- A confidence interval is a range of values, calculated from a sample, that is built to capture the true population value (a mean or a proportion) a stated share of the time. For 25 measurements with a mean of 50 and a standard deviation of 8, the 95% interval for the population mean is 46.6978 to 53.3022.
- What does 95% confidence actually mean?
- It describes the method, not one interval: if you drew many samples and built a 95% interval from each, about 95% of those intervals would contain the true value. Any single interval either contains it or it does not, so “there is a 95% probability the mean is in this range” is a common but loose reading. A higher confidence level gives a wider interval; a larger sample gives a narrower one.
- When should I use z and when t?
- Use t whenever the standard deviation comes from your sample (the usual case): the t distribution has heavier tails to allow for the extra uncertainty in s, and its shape depends on the degrees of freedom, n − 1. Use z only when the population standard deviation σ is genuinely known. With the same numbers (mean 50, SD 8, n 25) the 95% t interval is 46.6978 to 53.3022 (t* = 2.0639) and the z interval is 46.8641 to 53.1359 (z* = 1.96). The two get closer as n grows.
- What is the difference between margin of error and standard error?
- The standard error is the standard deviation of the sample mean, s ÷ √n (1.6 in the example). The margin of error is the standard error scaled by the critical value: E = t* × SE = 2.0639 × 1.6 = 3.3022. The interval is the sample mean plus and minus the margin of error.
- How do the 90%, 95% and 99% intervals compare?
- Higher confidence needs a larger critical value, so the interval is wider. For the example the margin of error is 2.7374 at 90%, 3.3022 at 95% and 4.4751 at 99%. The 95% level is the usual default; the tables above list z* and t* for each level.
- How do I find the confidence interval for a proportion?
- Switch to “A proportion” and enter the number of successes and trials. For 45 successes in 120 trials the sample proportion is 0.375 (37.5%), and the 95% Wilson score interval is 0.2935 to 0.4642 (29.35% to 46.42%). The calculator also shows the Wald interval, 0.2884 to 0.4616 (28.84% to 46.16%), for comparison.
- Should I use the Wald or the Wilson interval?
- The Wald interval, p̂ ± z* × √(p̂(1 − p̂) ÷ n), is the textbook formula but it is unreliable for small samples and for proportions near 0 or 1: its real coverage can fall well below the stated level. The Wilson score interval stays well behaved in those cases and is the better default. With 45 successes in 120 trials they differ slightly (Wilson 0.2935 to 0.4642 (29.35% to 46.42%), Wald 0.2884 to 0.4616 (28.84% to 46.16%)); with 0 successes in 20 the Wald interval collapses to 0 to 0 (0% to 0%) while the Wilson interval is 0 to 0.1611 (0% to 16.11%).
- How large a sample do I need for a given margin of error?
- For a mean with a known or assumed standard deviation σ, n = (z* × σ ÷ E)², rounded up. To get a 95% margin of error of 2 when σ is 8, n = (1.960 × 8 ÷ 2)² = 61.46, so 62 observations. Use the calculator’s margin of error to check the result for your own numbers.
- How is the t critical value calculated, and how accurate is it?
- The calculator evaluates the Student t distribution through the regularized incomplete beta function and inverts it with a bracketed Newton iteration, so t* is exact to about 12 digits for ordinary sample sizes (df up to the millions; beyond 10 million degrees of freedom the normal expansion takes over). Its test suite checks the values against the NIST/SEMATECH t table: for example, 2.228 at 10 degrees of freedom and 1.980 at 120, each 95% two-sided. The z values come from the same normal functions as the z-score calculator.
- How do I get the interval from a list of numbers?
- Switch to “A mean from a list of numbers” and paste them. Numbers are read by the same parser as the average and standard deviation calculators (commas, spaces and new lines separate them; text that is not a number is ignored and listed), then x̄ and the sample standard deviation s (n − 1) are found exactly. For the sample list the mean is 12.4375, s is 0.6479 and the 95% interval is 11.8958 to 12.9792. The list stays on your device.
- What assumptions does the interval make?
- The t interval assumes the observations are independent and roughly normally distributed, or that the sample is large enough for the mean to be close to normal (a common rule of thumb is about 30 or more, less for symmetric data). Strong skew or outliers in a small sample make it unreliable. A confidence interval also only reflects random sampling error: it says nothing about bias in how the sample was collected.
- What if I know σ?
- Choose “Known” for the standard deviation and enter σ. The calculator then uses the normal critical value z* instead of t* and no degrees of freedom. For the example numbers that gives 46.8641 to 53.1359 with z* = 1.96.
- Can the sample size be tiny?
- For a mean with σ unknown you need at least 2 observations (df = n − 1 must be at least 1), but the interval is very wide: with 25 observations and the same s the margin of error is 3.3022, while with n = 2 the 95% critical value is t* = 12.706. For a proportion a sample of 1 is allowed, but the Wilson interval will be correspondingly wide.
- Why does the interval get narrower with a bigger sample?
- The standard error is s ÷ √n, so the interval shrinks roughly with the square root of the sample size: quadrupling n about halves it. With a mean of 50 and s of 8, the 95% margin of error is 1.5874 at n = 100 and 3.3022 at n = 25, and the critical value t* also falls as the degrees of freedom rise, 1.9842 at n = 100 against 2.0639 at n = 25. To halve a margin of error you need about four times as many observations, which is why precision gets expensive.
- How many observations do I need for a margin of error of 1?
- With σ taken as 8, n = (z* × σ ÷ E)² gives 246 observations for a 95% margin of error of 1, and 425 for 99%. These use z*, so they are slightly low when σ is only estimated from a small sample: the t critical value is a little larger than z*, so check the result with the t interval above. The table of sample sizes lists other margins of error, and the sample size calculator covers the same question in more detail.
- What is the margin of error of a poll with 1,000 respondents?
- For a proportion near 50%, the Wald 95% margin of error with 1,000 respondents is ±3.1%, and with 400 it is ±4.9%. Going the other way, a margin of ±3 percentage points at 95% confidence needs about 1,068 respondents for an answer near 50%. The margin is smaller for answers far from 50%, and it covers random sampling error only, not wording, non-response or the way people were selected.
- What interval do I get when every trial was a success?
- The Wald interval collapses to a single point, 1 to 1 (100% to 100%) for 20 successes in 20 trials, which would claim no uncertainty at all. The Wilson score interval stays wide enough to be honest: 0.8389 to 1 (83.89% to 100%). The same happens with no successes, where Wilson gives 0 to 0.1611 (0% to 16.11%) for 0 in 20. With so few trials, the upper or lower limit is the useful part of the answer.
- Is a 95% confidence interval a range that holds 95% of the data?
- No. A confidence interval is about where the population mean might lie, not where individual observations fall. With a mean of 50, s of 8 and n = 25, the interval for the mean is 46.6978 to 53.3022, but individual values spread much more widely: the standard deviation is 8, five times the standard error of 1.6. A range for individual observations is a prediction interval, which this calculator does not compute.
- Does the example interval use rounded values?
- Results are shown to 4 decimals with trailing zeros dropped (4 significant digits below 0.01), but every calculation runs at full precision, so a figure like 3.3022 may differ in the last digit from multiplying the rounded numbers by hand: t* × SE here is 3.3022 from the unrounded inputs.
How it works
For a mean the interval is x̄ ± c × σ̂ ÷ √n, where σ̂ is the sample standard deviation s (n − 1 divisor) and c = t* with n − 1 degrees of freedom, or σ and c = z* when σ is known. A list of numbers is read by the average calculator’s parser and summarised exactly by the standard deviation calculator’s code. The critical value t* is the inverse of Student’s t distribution at upper-tail area (1 − level) ÷ 2: the tail probability is ½ I(df ÷ (df + t²); df ÷ 2, ½), the regularized incomplete beta function evaluated by Lentz’s continued fraction with Lanczos log-gamma, and the inverse is found by Newton’s method kept inside a bracket and started from the Cornish-Fisher expansion; 1 and 2 degrees of freedom use their closed forms, and above 10 million degrees of freedom the expansion itself is used. In the test suite the values are checked against the NIST/SEMATECH e-Handbook t table to 3 decimals and against closed forms and round trips to about 11 digits. The normal z* comes from the z-score calculator’s inverse normal distribution (Acklam’s approximation refined by a Halley step). For a proportion with p̂ = x ÷ n, the Wald interval is p̂ ± z* √(p̂(1 − p̂) ÷ n) and the Wilson score interval is (p̂ + z*² ÷ 2n ± z* √(p̂(1 − p̂) ÷ n + z*² ÷ 4n²)) ÷ (1 + z*² ÷ n); both are cut off at 0 and 1. The confidence level must be above 1 and below 100, written as a percentage. Results are shown to 4 decimals. Welch two-sample intervals, intervals for a difference of means and bootstrap intervals are not covered. Everything runs in your browser and nothing you type is sent anywhere.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.6.7.2 Critical values of the Student’s t distribution
- NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.5.2 Confidence limits for the mean
- E. B. Wilson, Probable inference, the law of succession, and statistical inference, Journal of the American Statistical Association 22 (1927)
- L. D. Brown, T. T. Cai and A. DasGupta, Interval estimation for a binomial proportion, Statistical Science 16 (2001)
- Confidence interval, Wikipedia
- Student’s t-distribution, Wikipedia
- Binomial proportion confidence interval, Wikipedia
More free tools
- Z-Score CalculatorFind a z-score from a value, mean and SD or a list of numbers, with percentile, left-tail, right-tail and two-tailed probability and a normal curve.
- Standard Deviation CalculatorPaste numbers and get the standard deviation (sample and population), variance, mean, quartiles and z-scores, with the step-by-step working and a dot plot.
- Probability CalculatorFind P(A and B), P(A or B), P(not A) and P(A|B) for two events, binomial probabilities for repeated trials, and odds to probability, as exact fractions.
- Sample Size CalculatorFind the sample size for a survey from confidence level, margin of error and expected proportion, with finite population correction, or the margin from n.
- Normal Distribution CalculatorNormal distribution probabilities from a mean and standard deviation: below, above, between two values, outside a range, or the value at a percentile.
- P-Value CalculatorP-value from a z or t statistic for left, right and two-tailed tests, with the reject or fail to reject verdict at your alpha and critical values.
More: Statistics, probability and gradesAll math & numbersAll toolsHome & DIY calculators