Confidence Interval
Calculator
Calculate confidence intervals, margin of error, and required sample size instantly, with an interactive bell curve, Z and t distributions, step-by-step formula, and plain-English interpretation.
Confidence Interval Calculator: Z, t, Margin of Error and Sample Size
A confidence interval is a range of values, calculated from a sample, that is likely to contain the true population value you are trying to estimate, such as an average. Enter a sample mean, a standard deviation, a sample size, and a confidence level, and this calculator returns the interval, the margin of error, and the standard error. It works with the Z distribution (when the population standard deviation σ is known) or Student’s t distribution (when σ is estimated from the sample), and it can also work backwards to find the sample size you need. A bell curve shows where the interval sits, and the step-by-step panel shows every calculation.
📊 The formulas:
Z confidence interval: CI = x̄ ± z* · (σ / √n)
t confidence interval: CI = x̄ ± t* · (s / √n)
Margin of Error: MOE = z* · (σ / √n)
Required Sample Size: n = (z* · σ / MOE)²
Standard Error: SE = σ / √n (or s / √n)
How the Confidence Interval Formula Works
The calculator measures how far a sample mean is likely to sit from the true population mean. The distance is a multiplier (a critical value) times the standard error, and the interval is the sample mean plus and minus that distance. The standard error is the standard deviation divided by the square root of the sample size, so it shrinks as n grows. Everything is in the same units as your data.
The four modes use the same pieces. CI, Z treats the standard deviation you enter as the known population σ and uses the normal critical value. CI, t treats it as the sample s and uses Student’s t critical value with n − 1 degrees of freedom. Margin of Error returns z* × σ/√n by itself. Sample Size solves that formula for n and rounds up. The NIST/SEMATECH e-Handbook of Statistical Methods gives the same confidence limits for the mean, using the t value when the standard deviation is estimated from the sample.
Step-by-step calculation walkthrough
Step 1: Identify the inputs. A bottling line fills cartons with a process standard deviation known from long-run records. A quality check of 64 cartons gives a mean fill of 502.3 ml, with σ = 4 ml. You want a 95% confidence interval in Z mode.
Step 2: Apply the formula. CI = x̄ ± z* × (σ ÷ √n), where z* is the normal critical value for 95% confidence.
Step 3: Perform the calculation. Standard error = 4 ÷ √64 = 4 ÷ 8 = 0.5. The critical value is z* = 1.96 (1.959964 before rounding). Margin of error = 1.96 × 0.5 = 0.98. Interval = 502.3 ± 0.98 = (501.32, 503.28).
Step 4: Interpret the result. You can be 95% confident that the line’s true average fill is between 501.32 and 503.28 ml. The interval is 1.96 ml wide, and the margin of error is only 0.2% of the mean, so the estimate is precise. If the label says 500 ml, the whole interval sits above it.
📊 The headline interval, the eight result boxes, the bell curve, the step-by-step panel, the interpretation, and the PDF all come from this one calculation. Changing any input updates all of them together.
Assumptions and limitations: the formula assumes a random sample, independent observations, and a sampling distribution of the mean that is roughly normal (reasonable for large n, or for any n when the population itself is roughly normal). It measures sampling uncertainty only. It does not correct for biased sampling, measurement error, or data that were not collected randomly.
Z-Score Reference for Common Confidence Levels
| Confidence | α | α/2 | z* | Use case |
|---|---|---|---|---|
| 📊 80% | 0.20 | 0.10 | 1.2816 | Exploratory research |
| 📊 85% | 0.15 | 0.075 | 1.4395 | Preliminary studies |
| 📊 90% | 0.10 | 0.05 | 1.6449 | Social science |
| 📊 95% | 0.05 | 0.025 | 1.9600 | Standard (most research) |
| 📊 98% | 0.02 | 0.01 | 2.3263 | Rigorous studies |
| 📊 99% | 0.01 | 0.005 | 2.5758 | High-stakes research |
| 📊 99.9% | 0.001 | 0.0005 | 3.2905 | Safety-critical testing |
Understanding the Components
Standard Error (SE)
SE = σ/√n measures how much the sample mean varies from sample to sample. Larger n reduces SE, narrowing the confidence interval. SE is the foundation of all CI calculations.
Margin of Error (MOE)
MOE = z* × SE is the “±” part of the confidence interval. It determines how far from the sample mean the interval extends. Smaller MOE means more precise estimation.
Critical Value (z* or t*)
The multiplier from the Z or t distribution corresponding to the chosen confidence level. At 95% confidence, z* = 1.96. Higher confidence → larger critical value → wider interval.
Confidence Level
The probability (e.g., 95%) that the interval contains the true population mean. It does NOT mean there’s a 95% chance the mean is in this specific interval. It means 95% of such intervals (from repeated sampling) would contain the mean.
When to Use Z vs t Distribution
The choice between Z and t depends on two factors: whether the population standard deviation (σ) is known, and the sample size. Use the Z distribution when: (1) the population σ is known (rare in practice), or (2) the sample size is very large (n ≥ 120, where t ≈ z). Use the t distribution when: (1) σ is unknown and estimated from the sample standard deviation s, and (2) especially when n < 30. The t distribution has heavier tails than the normal distribution, producing wider confidence intervals that account for the additional uncertainty of estimating σ from s. As n increases, the t distribution approaches the Z distribution. At 120 degrees of freedom the 95% critical values are 1.980 for t and 1.960 for z, a gap of about 1%.
The 95% Confidence Interval
The 95% confidence level is the most widely used standard in scientific research and is often the default when no specific level is stated. At 95% confidence, z* = 1.96 (commonly rounded to 2.0 for quick calculations). The interpretation: if you were to take 100 random samples and compute a 95% CI from each, approximately 95 of those intervals would contain the true population mean. The remaining 5 would not. That’s the 5% risk (α = 0.05) you accept when using 95% confidence. Important: a 95% CI does NOT mean “there is a 95% probability that the true mean lies in this interval.” The true mean is a fixed (unknown) value, so it either is or isn’t in the interval. The 95% refers to the long-run success rate of the method, not the probability for any single interval.
Sample Size and Precision
Sample size has a dramatic effect on confidence interval width because SE = σ/√n. Doubling n reduces the interval width by √2 ≈ 29%, not 50%. To halve the interval width, you must quadruple n. For example, with σ = 10 and 95% confidence: n = 25 gives MOE = 1.96 × 10/5 = 3.92; n = 100 gives MOE = 1.96 × 10/10 = 1.96 (half the MOE but 4× the sample size); n = 400 gives MOE = 1.96 × 10/20 = 0.98. The Sample Size mode of this calculator reverses the formula: given a desired MOE, confidence level, and σ, it computes the minimum n needed. This matters for research planning: collecting too few subjects wastes resources on inconclusive results, and collecting too many wastes time and money on unnecessary precision.
Worked Example: Clinical Trial
A pharmaceutical researcher measures blood pressure reduction in n = 64 patients taking a new medication. The sample mean reduction is x̄ = 12.5 mmHg with sample standard deviation s = 8.0 mmHg. Calculate the 95% confidence interval using the t distribution.
- Step 1: SE = s / √n = 8.0 / √64 = 8.0 / 8 = 1.0
- Step 2: df = n − 1 = 63. t* at 95% with df=63 ≈ 1.998
- Step 3: MOE = 1.998 × 1.0 = 1.998
- Step 4: CI = 12.5 ± 1.998 = (10.502, 14.498)
Interpretation: We are 95% confident that the true mean blood pressure reduction for the population taking this medication is between 10.5 and 14.5 mmHg. Since the entire interval is above zero, the medication produces a statistically significant reduction.
Worked Example: Market Research
A market researcher surveys n = 400 consumers and finds a mean willingness-to-pay of x̄ = $47.50 with σ = $15 (known from prior research). Calculate the 90% CI.
- Step 1: SE = 15 / √400 = 15 / 20 = 0.75
- Step 2: z* at 90% = 1.6449
- Step 3: MOE = 1.6449 × 0.75 = 1.2337 (the calculator carries more decimals of z and shows 1.2336)
- Step 4: CI = 47.50 ± 1.23 = ($46.27, $48.73)
Interpretation: We are 90% confident that the true average willingness-to-pay in the population is between $46.27 and $48.73, a narrow range that gives usable pricing guidance.
Research and Academic Applications
Confidence intervals are required in virtually all published research. Medical journals follow guidance from the International Committee of Medical Journal Editors, which tells authors to present findings with indicators of uncertainty such as confidence intervals and to avoid relying only on P values. An interval shows the direction and size of an effect and how uncertain it is, which a p-value alone does not. Social science: survey results report margins of error (which are half of the CI width). “52% ± 3% support the policy” means the 95% CI is (49%, 55%). Meta-analyses: forest plots display CIs for each study’s effect size, with overlapping CIs suggesting consistent findings across studies. Quality control: manufacturing uses a CI for the process mean to check that the average is on target. A 99% CI that sits well inside the tolerance band shows the average is fine, but it does not show that individual parts are in tolerance, which needs a separate capability analysis.
Finance and Business Applications
Financial analysts use confidence intervals for risk assessment and forecasting. Value at Risk (VaR) is related but not the same thing. A 95% VaR is a percentile of the distribution of individual returns, not a confidence interval for the average return, so it uses the standard deviation of returns directly instead of the standard error. Revenue forecasting: a sales forecast of “$10M ± $1.5M at 90% confidence” communicates both the estimate and its reliability. A/B testing: digital marketers compute CIs for conversion rate differences. If the CI for the difference excludes zero, the test result is statistically significant. Audit sampling: auditors use CIs to extrapolate findings from a sample of transactions to the entire population, determining whether misstatements are material.
Healthcare and Epidemiology
Healthcare relies on CIs for clinical decision-making. Drug efficacy: if the 95% CI for a treatment effect lies entirely above zero (for a beneficial outcome), the drug is considered statistically effective. Diagnostic accuracy: sensitivity and specificity of medical tests are reported with CIs to indicate precision. Epidemiological studies: relative risk and odds ratios include CIs. An odds ratio of 2.3 (95% CI: 1.5–3.5) means the association is statistically significant (CI excludes 1.0). Public health policy: vaccine trials report efficacy with an interval. The Pfizer-BioNTech trial published in the New England Journal of Medicine reported 95% efficacy with a 95% credible interval of 90.3 to 97.6. That is a Bayesian credible interval, which is read differently from the frequentist confidence intervals this calculator produces (see the Bayesian section below).
Common Confidence Interval Mistakes
- Misinterpreting the confidence level. “95% confident” does NOT mean “95% probability the mean is in this interval.” The true mean is fixed, and the 95% refers to the method’s long-run success rate across many samples.
- Using Z when t is appropriate. If σ is unknown (estimated from sample s) and n < 30, the Z distribution produces intervals that are too narrow, so use the t distribution, which accounts for the additional uncertainty.
- Confusing CI width with precision. A narrow CI isn’t automatically “better.” It describes the precision of the estimate, not its accuracy: a biased sample can give a very narrow interval around the wrong value.
- Ignoring assumptions. CIs assume random, independent sampling from a population. Non-random samples (convenience, volunteer, self-selected) violate this assumption and produce misleading intervals.
- Confusing CI with prediction interval. A CI estimates where the population MEAN lies. A prediction interval estimates where an individual observation might fall, and prediction intervals are always wider.
3 Real-Life Examples
Three situations, each using a different mode of the calculator above. The figures are what the calculator returns for these inputs.
| Situation | Mode and inputs | Result | What it means |
|---|---|---|---|
| Testing the battery life of a new laptop with a small sample | CI, t: mean 8.4 hours, s = 1.2, n = 16, 95% confidence | (7.7606, 9.0394) hours. SE = 0.3, t = 2.1314 (df = 15), margin of error ±0.6394 (7.61% of the mean) | With only 16 units the t value is 2.1314, about 9% larger than z (1.96). Using Z by mistake would give the narrower, overconfident interval (7.812, 8.988). |
| Finding the margin of error for an opinion poll of 1,000 people | Margin of Error: σ = 0.5 (the most cautious value for a proportion), n = 1,000, 95% | MOE = ±0.031, with SE = 0.0158 and z = 1.96 | That is about ±3.1 percentage points. If 54% support a policy, the 95% interval is roughly 50.9% to 57.1%. |
| Planning a blood pressure study before recruiting anyone | Sample Size: σ = 12 mmHg from earlier studies, desired MOE = ±2 mmHg, 95% | (1.96 × 12 ÷ 2)² = 138.29, rounded up to n = 139 | You need at least 139 participants. Because the plan uses z with an estimated σ, recruit a few extra to cover dropouts and the slightly wider t interval. |
These are statistical estimates, not medical, financial, or engineering advice. Check the assumptions listed below before relying on an interval.
Important Notes
- The standard deviation means different things in different modes. In CI, Z the number you enter is treated as the known population σ. In CI, t it is treated as the sample s. Margin of Error and Sample Size always use the normal (z) value, so for small samples they slightly understate the true margin.
- The t critical value is exact at 1 and 2 degrees of freedom, and an approximation above that. Samples of 2 or 3 (1 or 2 degrees of freedom) use an exact closed-form formula. From 3 degrees of freedom up it switches to a series approximation, which matches exact tables to within about 0.1% at 3 degrees of freedom and to four decimals from about 7 degrees of freedom onward. From 120 degrees of freedom up the calculator uses the normal value, about 1% below the exact t at 95%. For published results, check a t table or software regardless.
- The confidence level is rounded in the headline text. Choosing 99.9% shows “100% CI” and “100% confident” in the headline and interpretation, and 95.5% shows as 96%. The interval itself is calculated with the exact level you entered.
- Invalid entries do not clear the result. The sample size must be at least 2, the standard deviation above 0, and the confidence level between 0 and 100. If an entry breaks these rules, the previous result stays on screen, so check that the displayed inputs match what you typed.
- Rounding. Results show up to four decimals and drop trailing zeros, so 1.9600 appears as 1.96. Relative MOE is the margin divided by the absolute mean, so it shows ∞% when the mean is 0.
- The bell curve is a normal curve. It is drawn with a normal shape even in t mode, and in Margin of Error and Sample Size modes it is centered on 0 to show the ± range.
- Proportions are approximate. The normal method used here is a rough guide for small samples or proportions near 0% or 100%, where other interval methods work better.
- A confidence interval does not fix a biased sample. It describes sampling variation only. For clinical, regulatory, or other high-stakes work, have a statistician review the analysis.
- Privacy. Calculations and the PDF are created in your browser. Nothing you enter is sent to a server.
Related Statistical Calculators
Frequently Asked Questions
The Bell Curve Visualization
The calculator displays an SVG bell curve (normal distribution) with the confidence region shaded in purple. The curve represents the sampling distribution of the mean, the theoretical distribution of sample means you would get from repeated random sampling. It is always drawn as a normal curve, even in t mode, where the true curve has slightly heavier tails. The centre vertical line marks the sample mean (x̄). The two dashed vertical lines mark the lower and upper bounds of the confidence interval. The shaded area between the bounds represents the confidence level (e.g., 95% of the area under the curve). The unshaded tails represent the combined α probability: the chance that a confidence interval computed from a random sample would NOT contain the true population mean. This visualization makes the relationship between confidence level, interval width, and tail probability intuitively clear: increasing the confidence level from 90% to 99% visibly expands the shaded region and pushes the bounds further from the centre.
Effect of Confidence Level on Interval Width
The confidence level directly controls interval width through the critical value multiplier. For the same data (x̄ = 50, σ = 10, n = 100): at 80% confidence, z* = 1.282, MOE = 1.282, CI = (48.72, 51.28), which is narrow but only 80% reliable. At 90%, z* = 1.645, MOE = 1.645, CI = (48.36, 51.64). At 95%, z* = 1.960, MOE = 1.960, CI = (48.04, 51.96), the standard. At 99%, z* = 2.576, MOE = 2.576, CI = (47.42, 52.58), which is wide but very reliable. At 99.9%, z* = 3.291, MOE = 3.291, CI = (46.71, 53.29). The trade-off is fundamental: higher confidence means wider intervals. There is no way to simultaneously increase confidence AND decrease interval width without increasing the sample size n.
Confidence Intervals for Proportions
While this calculator focuses on means, the same logic applies to proportions (percentages). For a proportion p estimated from n observations, the standard error is SE = √(p(1−p)/n), and the CI is p ± z* × SE. Example: a survey of n = 1,000 finds 54% support a policy (p = 0.54). SE = √(0.54 × 0.46 / 1000) = 0.0158. At 95%: MOE = 1.96 × 0.0158 = 0.031 = 3.1 percentage points. CI = (50.9%, 57.1%). To use this calculator for proportions: enter the proportion as the “mean” (0.54), use √(p(1−p)) as the SD (√(0.54×0.46) = 0.4984), and enter your n. The resulting MOE applies to the proportion scale.
Multiple Comparisons and Bonferroni Correction
When computing multiple confidence intervals simultaneously (e.g., comparing 10 treatment groups), the family-wise error rate increases. If each CI is at 95% confidence, the probability that ALL 10 intervals contain their true parameters is 0.95¹⁰ = 0.599, so there is only about 60% confidence that every interval is correct. The Bonferroni correction addresses this by using α/k for each of k intervals: for 10 intervals at 95% family-wise confidence, use 99.5% confidence per interval (α = 0.05/10 = 0.005 per comparison). The calculator supports custom confidence levels, so enter 99.5 for Bonferroni-corrected intervals when making 10 simultaneous comparisons.
Bayesian vs Frequentist Intervals
The confidence intervals computed by this calculator follow the frequentist interpretation: the interval is constructed from the data using a procedure that, in repeated sampling, captures the true parameter a specified percentage of the time. The alternative Bayesian approach produces “credible intervals” that directly state the probability the parameter lies within the interval, but requires specifying a prior distribution for the parameter. For non-informative priors and large samples, Bayesian credible intervals and frequentist confidence intervals often coincide numerically. The distinction matters philosophically: the frequentist CI answers “how reliable is this procedure?” while the Bayesian credible interval answers “given the data, where is the parameter?” This calculator uses the frequentist approach because it requires no prior assumptions beyond the sampling distribution.
Power Analysis and Sample Size Planning
The calculator’s Sample Size mode solves the inverse problem: given a desired margin of error, what n is needed? This is critical for research planning because underpowered studies waste resources on results too imprecise to be useful. Example: a researcher wants the 95% CI for mean reaction time to have a margin of error no larger than ±5 ms, with σ estimated at 25 ms from pilot data. Required n = (1.96 × 25 / 5)² = (9.8)² = 96.04 → round up to n = 97. Recruiting 97 participants should give a margin of error of about ±5 ms at 95% confidence, provided σ really is close to 25 ms. Rule of thumb: to halve the MOE, quadruple n; to reduce MOE by 10×, multiply n by 100. The √n relationship means precision is expensive.
Reporting Confidence Intervals in Publications
Academic journals and style guides (APA, AMA, Chicago) prescribe specific formats for reporting CIs, and the ICMJE guidance linked above asks medical authors to report uncertainty alongside every estimate. APA format: “M = 50.0, 95% CI [48.04, 51.96]”, using square brackets and a comma separator. Medical journals: “mean difference = 12.5 mmHg (95% CI: 10.5 to 14.5)”, using parentheses and “to” for the range. Epidemiology: “OR = 2.3 (95% CI 1.5–3.5)”, using an en dash for the range. The calculator provides the interval in (lower, upper) format with full decimal precision; adapt the notation to your publication’s style guide. When presenting CIs in tables, use consistent decimal precision across all rows and align the brackets or parentheses for readability. In oral presentations, state the CI verbally as “the 95% confidence interval ranges from [lower] to [upper]”. Avoid saying “the mean is between [lower] and [upper]” because the interval estimates the population mean, not the range of individual values. For non-technical audiences, simplify to “we’re fairly confident the true average is somewhere between [lower] and [upper]”, which captures the essence without requiring statistical literacy. In executive summaries and business reports, present the point estimate prominently and note the CI as a measure of precision: “revenue per customer averages $47.50, with a margin of error of approximately $1.23 at 90% confidence.” Always report the confidence level, the point estimate (mean), and the full interval, never just the point estimate alone. Many journals now ask for CIs in addition to (or instead of) p-values, because intervals show both statistical and practical significance.
Calculate your confidence interval now 📊
Z & t distributions, bell curve, sample size planner: enter your data for an instant CI calculation.
Calculate CI ↑