Skip to main content
ponderloop

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

  1. Standard error: SE = s ÷ √n = 8 ÷ √25 = 1.6.
  2. Critical value: t* for 95% confidence with n − 1 = 24 degrees of freedom leaves 0.025 in each tail, so t* = 2.0639.
  3. Margin of error: E = t* × SE = 2.0639 × 1.6 = 3.3022.
  4. Interval: x̄ ± E = 50 ± 3.3022 = 46.6978 to 53.3022.

Critical t-values by degrees of freedom, with z* in the last row

Two-sided critical values t* for 90%, 95% and 99% confidence, computed by the calculator’s own inverse Student t and printed to 3 decimals like the NIST/SEMATECH t table. The last row is the normal z* that t* approaches as the sample grows.
Degrees of freedom (df = n − 1)90% confidence95% confidence99% confidence
16.31412.70663.657
22.9204.3039.925
32.3533.1825.841
42.1322.7764.604
52.0152.5714.032
101.8122.2283.169
151.7532.1312.947
201.7252.0862.845
241.7112.0642.797
301.6972.0422.750
601.6712.0002.660
1201.6581.9802.617
∞ (z*)1.6451.9602.576

Critical z-values for common confidence levels

Use z* when the population standard deviation σ is known, or for a proportion.
Confidence levelTail area each sideTwo-sided z*
80%0.11.282
90%0.051.645
95%0.0251.960
98%0.012.326
99%0.0052.576
99.9%0.00053.291

How the interval for a mean narrows as the sample grows (mean 50, s 8, 95% confidence)

The 95% t interval for a mean of 50 and a standard deviation of 8 at eight sample sizes; the margin falls roughly with the square root of n.
Sample size nDegrees of freedomt*Standard errorMargin of errorInterval
542.77643.57779.933340.0667 to 59.9333
1092.26222.52985.722944.2771 to 55.7229
15142.14482.06564.430345.5697 to 54.4303
25242.06391.63.302246.6978 to 53.3022
30292.04521.46062.987247.0128 to 52.9872
50492.00961.13142.273647.7264 to 52.2736
100991.98420.81.587448.4126 to 51.5874
4003991.96590.40.786449.2136 to 50.7864

The same sample at different confidence levels (n 25, mean 50, s 8)

Higher confidence needs a larger critical value and gives a wider interval; each row uses 24 degrees of freedom.
Confidence levelt*z*Margin of error (t)t intervalz interval (σ known)
80%1.31781.28162.108547.8915 to 52.108547.9495 to 52.0505
90%1.71091.64492.737447.2626 to 52.737447.3682 to 52.6318
95%2.06391.963.302246.6978 to 53.302246.8641 to 53.1359
98%2.49222.32633.987546.0125 to 53.987546.2778 to 53.7222
99%2.79692.57584.475145.5249 to 54.475145.8787 to 54.1213
99.9%3.74543.29055.992644.0074 to 55.992644.7352 to 55.2648

Sample size needed for a wanted margin of error when σ is 8

Observations needed, n = (z* × σ ÷ E)² rounded up, for σ = 8 and a wanted margin of error E at 90%, 95% and 99% confidence.
Wanted margin of error E90% confidence95% confidence99% confidence
0.56939841699
1174246425
24462107
3202848
4111627
571017

Wilson and Wald intervals for a proportion at 95% confidence

Successes out of trials, the sample proportion and the two intervals the calculator shows, from the no-success case to the all-success case.
SuccessesTrialsSample proportionWilson score intervalWald interval
0200 (0%)0 to 0.1611 (0% to 16.11%)0 to 0 (0% to 0%)
1200.05 (5%)0.008881 to 0.2361 (0.89% to 23.61%)0 to 0.1455 (0% to 14.55%)
5200.25 (25%)0.1119 to 0.4687 (11.19% to 46.87%)0.0602 to 0.4398 (6.02% to 43.98%)
10200.5 (50%)0.2993 to 0.7007 (29.93% to 70.07%)0.2809 to 0.7191 (28.09% to 71.91%)
18500.36 (36%)0.2414 to 0.4986 (24.14% to 49.86%)0.227 to 0.493 (22.7% to 49.3%)
451200.375 (37.5%)0.2935 to 0.4642 (29.35% to 46.42%)0.2884 to 0.4616 (28.84% to 46.16%)
951000.95 (95%)0.8882 to 0.9785 (88.82% to 97.85%)0.9073 to 0.9927 (90.73% to 99.27%)
20201 (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

The Wald margin of error at 95% confidence when half of n respondents give one answer, which is the widest case for a proportion.
Sample size nMargin of errorInterval 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

Each row is the calculator’s own answer for the mean, standard deviation, sample size and level in the first four columns, with s from the sample.
MeanStandard deviationSample sizeLevelStandard errort*Margin of errorConfidence interval
5082595%1.62.06393.302246.6978 to 53.3022
100153690%2.51.68964.223995.7761 to 104.2239
72.56.21699%1.552.94674.567467.9326 to 77.0674
5.41.110095%0.111.98420.21835.1817 to 5.6183
25040995%13.33332.30630.7467219.2533 to 280.7467
3.20.81299%0.23093.10580.71732.4827 to 3.9173
120015040095%7.51.965914.74451185.2555 to 1214.7445

How to find a confidence interval for a mean

  1. 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.
  2. 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.
  3. 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%).
  4. Multiply to get the margin of error. E = t* × SE = 2.0639 × 1.6 = 3.3022.
  5. 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

More: Statistics, probability and gradesAll math & numbersAll toolsHome & DIY calculators