What is the confidence interval?
Enter your sample's mean and standard deviation, or its count of successes, to get the confidence interval and the margin of error.
- Margin of error (±)
- 1.015054
The 95% confidence interval is 66.984946 to 69.015054 (68 ± 1.015054).
- Lower limit
- 66.984946
- Upper limit
- 69.015054
- Estimate
- 68
- Standard error
- 0.5
- Critical value
- 2.030108
Margin of error (±): 1.015054. The 95% confidence interval is 66.984946 to 69.015054 (68 ± 1.015054).
Where is the interval?
How to calculate
Computes a confidence interval for a population mean (t or z) or a population proportion at any confidence level, with the margin of error and standard error.
Example with the default inputs (Interval for a Mean, Sample mean (x̄) 68, Standard deviation 3, Standard deviation is From the sample (t), Sample size (n) 36, Confidence level 95%): The 95% confidence interval is 66.984946 to 69.015054 (68 ± 1.015054).
Method: Mean: x̄ ± t × s ÷ √n with n − 1 degrees of freedom (or z × σ ÷ √n for a known σ). Proportion: p̂ ± z × √(p̂(1 − p̂) ÷ n). The critical value has an upper tail of (1 − confidence) ÷ 2.
- The sample is random, and the sample mean is roughly normal (the data are close to normal or n is large).
- The proportion interval is the normal-approximation (Wald) interval; it works best when at least 5 successes and 5 failures are counted. Its limits are cut to 0 and 1.
Worked examples
Each example is checked against the calculator on every build.
- Interval for a Mean, Sample mean (x̄) 68, Standard deviation 3, Standard deviation is From the sample (t), Sample size (n) 36, Confidence level 95% gives Critical value 2.030108, Margin of error (±) 1.015054, Lower limit 66.984946, Upper limit 69.015054.Source: NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.2 Confidence Limits for the Mean. https://www.itl.nist.gov/div898/handbook/eda/section3/eda352.htm
- Interval for a Mean, Sample mean (x̄) 68, Standard deviation 3, Standard deviation is Known σ (z), Sample size (n) 36, Confidence level 90% gives Critical value 1.644854, Margin of error (±) 0.822427, Lower limit 67.177573, Upper limit 68.822427.Source: OpenStax, Introductory Statistics 2e, §8.1 A Single Population Mean using the Normal Distribution. https://openstax.org/books/introductory-statistics-2e/pages/8-1-a-single-population-mean-using-the-normal-distribution, Example 8.2 (z = 1.645, EBM = 0.8225, interval 67.18 to 68.82)
- Interval for a Mean, Sample mean (x̄) 9.26146, Standard deviation 0.022789, Standard deviation is From the sample (t), Sample size (n) 195, Confidence level 95% gives Lower limit 9.258241, Upper limit 9.264679.Source: NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.2 Confidence Limits for the Mean. https://www.itl.nist.gov/div898/handbook/eda/section3/eda352.htm (95% interval 9.258242 to 9.264679)
- Interval for a Proportion, Successes (x) 421, Sample size (n) 500, Confidence level 95% gives Estimate 0.842, Lower limit 0.81003, Upper limit 0.87397.Source: OpenStax, Introductory Statistics 2e, §8.3 A Population Proportion. https://openstax.org/books/introductory-statistics-2e/pages/8-3-a-population-proportion, Example 8.10 (p′ = 0.842, interval 0.810 to 0.874)
- Interval for a Proportion, Successes (x) 300, Sample size (n) 500, Confidence level 90% gives Estimate 0.6, Margin of error (±) 0.036037.Source: OpenStax, Introductory Statistics 2e, §8.3 A Population Proportion. https://openstax.org/books/introductory-statistics-2e/pages/8-3-a-population-proportion, Example 8.11 (EBP = 0.036, interval 0.564 to 0.636)
How it works
Let C be the confidence level in percent and α = 1 − C ÷ 100.
Mean, standard deviation from the sample (t). With sample mean x̄, sample standard deviation s, and size n:
- standard error SE = s ÷ √n
- critical value t* = the t with upper tail α ÷ 2 and n − 1 degrees of freedom
- margin of error = t* × SE, and the interval is x̄ − margin to x̄ + margin.
Mean, known σ (z). The same with σ in place of s and the standard normal z* (upper tail α ÷ 2) in place of t*.
Proportion. With x successes in n: p̂ = x ÷ n, SE = √(p̂ × (1 − p̂) ÷ n), margin = z* × SE, and the interval is p̂ − margin to p̂ + margin, with the lower limit raised to 0 and the upper limit lowered to 1 if they pass those bounds (the margin of error itself is not cut). This is the normal-approximation (Wald) interval.
The page shows the margin of error, the lower and upper limits, the estimate (x̄ or p̂), the standard error, and the critical value. For a proportion with fewer than 5 successes or fewer than 5 failures (x < 5 or n − x < 5), it also shows the caution "Fewer than 5 successes or 5 failures: this interval is rough."; with 0 or n successes the Wald interval has zero width.
Rules
- The confidence level is from 1% to 99.9999%.
- The standard deviation must be above 0. A t interval needs n of at least 2; a z interval allows n = 1.
- For a proportion, the successes are a whole number from 0 to n.
- α = (100 − C) ÷ 100 is worked out exactly from the typed confidence level. The critical values come from the inverse of the t and normal distributions, good to at least 11 significant digits at any degrees of freedom (checked against mpmath). From 1,000 degrees of freedom up, t* is found by Newton's method on the t tail computed as the integral of the t density.
- Results show up to 6 decimal places (6 significant digits below 0.0001), with halves rounded up.
Worked examples by hand
The default (x̄ = 68, s = 3, n = 36, 95%, t). SE = 3 ÷ 6 = 0.5. With 35 degrees of freedom t* = 2.030108, so the margin is 2.030108 × 0.5 = 1.015054 and the interval is 66.984946 to 69.015054.
Known σ (OpenStax Example 8.2: x̄ = 68, σ = 3, n = 36, 90%). z* = 1.644854 (tables: 1.645). Margin = 1.644854 × 0.5 = 0.822427; interval 67.177573 to 68.822427 (OpenStax: 67.18 to 68.82).
NIST data (x̄ = 9.261460, s = 0.022789, n = 195, 95%). SE = 0.022789 ÷ √195 = 0.001632; t* = 1.972268 with 194 degrees of freedom; margin = 0.003219; interval 9.258241 to 9.264679 (NIST: 9.258242 to 9.264679, from the unrounded data).
Proportion (OpenStax Example 8.10: 421 of 500, 95%). p̂ = 0.842; SE = √(0.842 × 0.158 ÷ 500) = 0.016312; z* = 1.959964; margin = 0.03197; interval 0.81003 to 0.87397 (OpenStax: 0.810 to 0.874).
Proportion at 90% (OpenStax Example 8.11: 300 of 500). p̂ = 0.6; SE = √(0.24 ÷ 500) = 0.021909; margin = 1.644854 × 0.021909 = 0.036037; interval 0.563963 to 0.636037.
Other questions people ask
What is a confidence interval?
It is a range of values, worked out from a sample, that is likely to contain the true population value. A 95% confidence interval comes from a method that captures the true value in 95% of samples. It does not mean the true value moves: any one interval either contains it or not.
How do I calculate a 95% confidence interval for a mean?
Take the sample mean plus or minus the critical value times the standard error: x̄ ± t × s ÷ √n, with n − 1 degrees of freedom. For x̄ = 68, s = 3, and n = 36, t = 2.0301, the margin is 2.0301 × 3 ÷ 6 = 1.015, and the interval is 66.985 to 69.015.
Should I use t or z?
Use t when you have the sample standard deviation, which is nearly always. Use z only when the population standard deviation σ is known from elsewhere. With large samples the two give almost the same interval.
What is the margin of error?
It is half the width of the interval: the critical value times the standard error. The interval is the estimate plus or minus the margin of error. Polls often report it, such as ±3 points.
Why is a 99% interval wider than a 95% interval?
To be more confident of catching the true value, the interval must cover more ground. The critical z rises from 1.96 at 95% to 2.576 at 99%, so the interval is about 31% wider.
How do I make the interval narrower?
Use a larger sample. The standard error shrinks with √n, so four times as many observations halve the margin of error. The sample size calculator finds the n for a margin you choose.
How is the interval for a proportion found?
With x successes in n, the sample proportion is p̂ = x ÷ n and the interval is p̂ ± z × √(p̂(1 − p̂) ÷ n). For 421 of 500 at 95%, p̂ = 0.842 and the interval is 0.810 to 0.874.