Interval estimate

Confidence interval for a mean calculator

Find the confidence interval for a population mean from a sample, using the t distribution. Paste data or enter the mean, SD and n, choose 90%, 95% or 99%, and see the interval, the margin of error and the t* multiplier.

  • t-based, as for any unknown SD
  • Margin of error shown as a sum
  • Same interval R's t.test prints

Sources checked on November 21, 2026. Results computed by the site's engine and tested against R and SciPy.

Input
Paste a column from a spreadsheet, or type numbers separated by spaces, commas or new lines.

95% confidence interval for the mean

Lower0.5956
Upper2.4844
Margin of error±0.9444
Mean1.5400
SD2.0179
n20
t* (df 19)2.0930

Margin of error = t* × SD / √n = 2.0930 × 2.0179 / √20 = 0.9444.

Assumptions check

  • Data: skewness 0.42; no values beyond 1.5 IQR from the quartiles.
Reproduce this result in R or Python

The interval is the confidence interval line that R and SciPy print for a one-sample t-test.

R

x <- c(0.7, -1.6, -0.2, -1.2, -0.1, 3.4, 3.7, 0.8, 0, 2, 1.9, 0.8, 1.1, 0.1, -0.1, 4.4, 5.5, 1.6, 4.6, 3.4)
t.test(x, mu = 0, alternative = "two.sided", conf.level = 0.95)

Python (SciPy)

from scipy.stats import ttest_1samp
x = [0.7, -1.6, -0.2, -1.2, -0.1, 3.4, 3.7, 0.8, 0, 2, 1.9, 0.8, 1.1, 0.1, -0.1, 4.4, 5.5, 1.6, 4.6, 3.4]
res = ttest_1samp(x, 0, alternative="two-sided")
print(res, res.df, res.confidence_interval(0.95))

What the interval means

A 95% confidence interval comes from a method that, over many samples, captures the true mean 95% of the time. For one sample, it is the set of values for the mean that the data do not rule out at the 5% level. It does not mean there is a 95% chance the true mean lies in this particular interval; the true mean is fixed and the interval either contains it or not.

Worked example: extra sleep

The calculator opens with all twenty extra-sleep values from Student's 1908 data. The mean is 1.54 hours, the SD 2.0179 and n = 20, so the standard error is 2.0179 / √20 = 0.4512. With 19 df, the 95% multiplier t* is 2.0930, giving a margin of error of 0.9444 and an interval of 0.5956 to 2.4844 hours. This is the interval in R's output for t.test on these data.

Levelt*Margin of errorInterval
90%1.72910.78020.7598 to 2.3202
95%2.09300.94440.5956 to 2.4844
99%2.86091.29090.2491 to 2.8309

Higher confidence buys a wider interval. Going from 95% to 99% here widens the margin of error by 37%.

Formula

x̄ ± t1−α/2, n−1 × s / √n

Use t rather than z whenever the SD is estimated from the sample, which is almost always. The difference matters most for small samples: with 5 values the 95% t* is 2.776, against 1.960 for z.

Sample size and the margin of error

The margin of error shrinks with the square root of n. To halve it you need about four times as many observations. For a rough planning figure, take a guess at the SD and solve for n: n ≈ (t* × SD / margin)², using a t* near 2 for a 95% interval.

Summary statistics and standard errors

If a paper reports a mean with its standard error (SEM) rather than its SD, multiply the SEM by √n to get the SD before using the summary input. Results from rounded summaries can differ slightly from the raw-data interval.

Intervals for differences

For the difference between two group means, use the independent samples calculator, which gives the Welch and Student intervals. For paired data, the paired calculator gives the interval for the mean difference. A one-sample test against a fixed value is in the one-sample calculator, and uses this same interval.

Sources