Confidence Interval Calculator

Calculate confidence intervals for means and proportions. Supports 90%, 95%, 99% or custom levels with margin of error and step-by-step formulas shown.

Calculate confidence intervals for population means and proportions. Supports 90%, 95%, 99%, or any custom confidence level. Uses z-distribution when the population standard deviation is known and t-distribution when it is not. Every result shows the margin of error, critical value, and step-by-step formula substitution.

Ad
Ad

About Confidence Interval Calculator

What Is a Confidence Interval?

A confidence interval gives a range of values that is likely to contain the true population parameter. A 95% confidence interval means: if you repeated this study many times with new samples each time, about 95% of those intervals would contain the true value.

CI = point estimate ± margin of error

CI = x̄ ± z* × (σ / √n)

Confidence Interval for a Mean (σ Known)

When you know the population standard deviation, use the z-distribution:

Worked example: A factory produces bolts with known standard deviation σ = 0.05 mm. A sample of 36 bolts has mean length 10.02 mm. Find the 95% CI.

  1. Sample mean (x̄) = 10.02 mm
  2. Standard error = σ / √n = 0.05 / √36 = 0.05 / 6 = 0.00833
  3. Critical value z* for 95% = 1.960
  4. Margin of error = 1.960 × 0.00833 = 0.01633
  5. CI = 10.02 ± 0.016 = (10.004, 10.036) mm

Confidence Interval for a Mean (σ Unknown)

When the population standard deviation is unknown (the common case), use the sample standard deviation s and the t-distribution with n-1 degrees of freedom:

CI = x̄ ± t* × (s / √n)

Worked example: 25 students have a mean test score of 78 with sample standard deviation s = 12. Find the 95% CI.

  1. Degrees of freedom = 25 - 1 = 24
  2. t* for 95% with 24 df = 2.064
  3. Standard error = 12 / √25 = 12 / 5 = 2.4
  4. Margin of error = 2.064 × 2.4 = 4.95
  5. CI = 78 ± 4.95 = (73.05, 82.95)

When to Use z vs t Distribution

Z-DistributionT-Distribution
Population σKnownUnknown (using sample s)
Sample sizeAny (often n > 30)Any (especially important for small n)
ShapeStandard normalWider tails, depends on df
As n increasesStays the sameApproaches z-distribution
Critical value (95%)Always 1.960Varies: 2.262 (df=9), 2.064 (df=24), 1.984 (df=100)

Confidence Interval for a Proportion

For categorical data (success/failure), the formula uses the normal approximation:

CI = p̂ ± z* × √(p̂(1-p̂)/n)

Worked example: In a survey of 400 people, 260 prefer product A. Find the 95% CI for the true proportion.

  1. Sample proportion p̂ = 260/400 = 0.65
  2. Standard error = √(0.65 × 0.35 / 400) = √(0.000569) = 0.02385
  3. Margin of error = 1.960 × 0.02385 = 0.04675
  4. CI = 0.65 ± 0.047 = (0.603, 0.697)
  5. We are 95% confident the true proportion is between 60.3% and 69.7%

How Confidence Level Affects Interval Width

Confidence Levelz*Margin of Error (relative)Interval Width
80%1.2820.65×Narrow
90%1.6450.84×Moderate
95%1.9601.00× (baseline)Standard
99%2.5761.31×Wide
99.9%3.2911.68×Very wide

There is always a tradeoff: higher confidence means a wider (less precise) interval. The standard in most research is 95%.

How Sample Size Affects Precision

Margin of error shrinks with the square root of sample size:

Sample Size (n)√nMargin of Error (σ=10, 95%)
255±3.92
10010±1.96
40020±0.98
1,00031.6±0.62
10,000100±0.20

To halve the margin of error, you need to quadruple the sample size. This diminishing return means there is a practical limit to how precise you can get.

Common Misinterpretations

A 95% confidence interval does NOT mean "the true mean has a 95% probability of lying in this interval". In frequentist statistics, the true parameter is fixed - the interval is what varies across repeated samples. The American Statistical Association's 2016 statement on statistical inference explicitly warns against this probability interpretation.

Wrong InterpretationCorrect Interpretation
"There is a 95% chance the true mean is in this interval"The true mean is fixed. 95% of intervals from repeated sampling would contain it.
"95% of the data falls in this interval"The interval is about the mean, not individual data points.
"This interval is definitely correct"There is a 5% chance (at 95% confidence) that this particular interval misses the true value.
"A wider CI means my study is worse"A wider CI usually means smaller n or more variability, not flawed methodology.
"Overlapping CIs mean no significant difference"Two 95% CIs can overlap and still represent a statistically significant difference (roughly 84% CIs need to not overlap to match p < 0.05).

How to Report Confidence Intervals in Practice

Modern research journals increasingly require confidence intervals alongside p-values. The CONSORT 2010 guidelines for clinical trials and the APA Publication Manual 7th edition both mandate CI reporting for primary outcomes. The standard format is: point estimate (95% CI: lower, upper) followed by units.

  • Mean difference: "Treatment group scored 4.2 points higher (95% CI: 1.8, 6.6)"
  • Proportion: "62% of respondents agreed (95% CI: 58%, 66%)"
  • Odds ratio: "OR = 1.45 (95% CI: 1.12, 1.88)"
  • Correlation: "r = 0.34 (95% CI: 0.18, 0.48)"

When the CI for a difference crosses zero (or the CI for a ratio crosses 1), the result is not statistically significant at the stated confidence level. When the CI is entirely positive or entirely negative, the direction of effect is supported at that level.

Assumptions Behind the Formulas

Confidence interval formulas make three core assumptions that can break with real data. The z and t formulas for means assume the sampling distribution of the mean is approximately normal, which relies on either a normally distributed population OR a large enough sample for the Central Limit Theorem to kick in.

  • Independence: Each observation must be independent. Cluster samples, repeated measures, and time series violate this and need adjusted standard errors.
  • Normality (for small n): With n below 30, the population itself should be roughly normal. With larger n, the CLT makes the sample mean approximately normal regardless.
  • Random sampling: The sample must be random. Convenience samples, self-selected responses, and biased sampling frames invalidate the probabilistic interpretation.
  • Proportion formula: The normal approximation needs n × p ≥ 5 AND n × (1-p) ≥ 5. For very rare events or near-0%/100% proportions, use the Wilson score interval or exact Clopper-Pearson instead.

Real-world survey work often uses finite population correction when sampling more than 5% of the population: SE becomes SE × √((N-n)/(N-1)), which shrinks the margin of error.

Bootstrapping as an Alternative

Bootstrap confidence intervals, introduced by Bradley Efron in 1979, work when parametric assumptions fail. Instead of using a formula, you resample the data with replacement thousands of times, recompute the statistic for each resample, and take the 2.5th and 97.5th percentiles as the 95% CI. Modern statistical software (R, Python, SAS) makes this trivial, and it handles medians, trimmed means, and other statistics where no closed-form formula exists.

For most introductory stats problems with reasonable sample sizes and roughly symmetric data, the z/t formulas produce nearly identical results to bootstrap methods. Stick with the formulas for coursework and simple reports; reach for bootstrap when you are working with skewed distributions, small samples, or unusual statistics.

One-Sided vs Two-Sided Intervals

This calculator produces two-sided confidence intervals, the standard in research. A two-sided 95% CI splits the 5% error across both tails (2.5% in each). One-sided intervals place the full 5% on one side, producing a single bound. They are appropriate when you only care about one direction of the effect.

Example: a drug regulator only cares whether a new medicine is at least as effective as the current standard. They would use a one-sided lower bound, where the critical value for 95% becomes 1.645 instead of 1.960. This makes the bound tighter but only informative in one direction. Most published research uses two-sided intervals unless there is a strong prior reason to exclude one direction.

Real-World Sample Sizes in Published Research

Looking at what actual studies use helps calibrate expectations. Political polling firms like YouGov and Gallup typically sample around 1,000-2,000 adults, producing margins of error around ±3 percentage points at 95%. Clinical trials for new drugs registered on ClinicalTrials.gov commonly use 100-500 participants per arm for phase 2 and 1,000-5,000 for phase 3. Educational research published in the Journal of Educational Psychology averages roughly 200-500 students per study.

Very large observational studies can push margin of error below ±0.5%, but diminishing returns kick in hard. Going from n=1,000 to n=4,000 cuts the margin in half; going from n=4,000 to n=16,000 cuts it in half again. At some point the bias from sampling methodology, non-response, or measurement error dwarfs the remaining sampling error, and adding more people stops helping.

Confidence Intervals vs Prediction Intervals vs Tolerance Intervals

Interval TypeWhat It EstimatesTypical Width
Confidence intervalA population parameter (mean, proportion)Narrows with larger n
Prediction intervalA single future observationWider than CI; approaches population spread
Tolerance intervalA specified proportion of the populationWidest; combines sampling and individual variation

Confusing these is a common mistake. If a factory asks "what range will 99% of our bolts fall in?", that is a tolerance interval, not a confidence interval. If a doctor asks "what is the likely cholesterol reading for the next patient?", that is a prediction interval. If a researcher asks "what is the likely average cholesterol in the population?", that is a confidence interval.

To determine the sample size needed for a target margin of error, the sample size calculator works backwards from your precision requirements. For computing the standard deviation from raw data, the standard deviation calculator handles both population and sample formulas. For hypothesis testing using these same critical values, the p-value calculator converts test statistics into p-values.

All calculations run in your browser. No data is sent to any server.

Sources

Frequently Asked Questions

What is a confidence interval?

A confidence interval gives a range of values that likely contains the true population parameter. A 95% CI means if you repeated the study many times, about 95% of those intervals would contain the true value.

When should I use z vs t distribution?

Use the z distribution when the population standard deviation is known, or for proportions. Use the t distribution when the population standard deviation is unknown and you are using the sample standard deviation instead. The t distribution has heavier tails for smaller samples.

What does margin of error mean?

Margin of error is the plus-or-minus value added to and subtracted from the point estimate. It equals the critical value times the standard error. A smaller margin of error means a more precise estimate.

How do I choose a confidence level?

95% is the most common in research. Use 99% when you need more certainty, like in medical or safety studies. 90% is sometimes used when you want a narrower interval. Higher confidence means a wider interval.

What is the difference between standard error and standard deviation?

Standard deviation measures spread in the data. Standard error measures the precision of a sample statistic like the mean. Standard error equals the standard deviation divided by the square root of the sample size.

Link to this tool

Copy this HTML to link to this tool from your website or blog.

<a href="https://toolboxkit.io/tools/confidence-interval-calculator/" title="Confidence Interval Calculator - Free Online Tool">Try Confidence Interval Calculator on ToolboxKit.io</a>