Confidence Interval Calculator
Calculate confidence intervals for means and proportions. Compare z-intervals and t-intervals, use Wilson score method for proportions, and determine
Confidence Interval Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: CI = x-bar +/- z * (s / sqrt(n)) | CI(p) = p-hat +/- z * sqrt(p*q/n)
Worked example โ 95% CI: [129.63, 140.37] mmHg. We are 95% confident the population mean BP is between 129.63 and 140.37 mmHg.
Formula
CI = x-bar +/- z * (s / sqrt(n)) | CI(p) = p-hat +/- z * sqrt(p*q/n)
For means: the margin of error is the critical z-value (or t-value for small samples) times the standard error (SD / sqrt of sample size). For proportions: the standard error uses p-hat*(1-p-hat)/n. The Wilson score interval provides improved coverage for proportions.
Worked Examples
Example 1: 95% CI for Mean Blood Pressure
Problem:A sample of 30 patients has a mean systolic BP of 135 mmHg with SD of 15 mmHg. Calculate the 95% confidence interval.
Solution:SE = 15 / sqrt(30) = 2.739 z = 1.960 for 95% CI MOE = 1.960 x 2.739 = 5.369 Lower = 135 - 5.369 = 129.631 Upper = 135 + 5.369 = 140.369
Result:95% CI: [129.63, 140.37] mmHg. We are 95% confident the population mean BP is between 129.63 and 140.37 mmHg.
Example 2: 95% CI for Proportion (Success Rate)
Problem:60 out of 100 patients responded to treatment. Calculate the 95% CI for the response rate.
Solution:p-hat = 60/100 = 0.60 SE = sqrt(0.60 x 0.40 / 100) = 0.04899 Wald MOE = 1.960 x 0.04899 = 0.09602 Wald CI: [0.504, 0.696] Wilson CI: [0.502, 0.691] (more accurate)
Result:Wald 95% CI: [50.4%, 69.6%] | Wilson 95% CI: [50.2%, 69.1%]. Treatment response rate is significantly above 50%.
Frequently Asked Questions
What is a confidence interval and what does it tell us?
A confidence interval (CI) provides a range of plausible values for a population parameter based on sample data. A 95% CI means that if you repeated the sampling process many times and computed a CI each time, approximately 95% of those intervals would contain the true population parameter. It does NOT mean there is a 95% probability the true value lies in any single interval. The CI width reflects precision: narrower intervals indicate more precise estimates. Confidence intervals are more informative than p-values alone because they show both the direction and magnitude of an effect, along with the uncertainty in the estimate.
When should I use a z-interval versus a t-interval?
Use a z-interval when the population standard deviation is known (rare in practice) or when the sample size is large (n >= 30), as the Central Limit Theorem ensures the sampling distribution is approximately normal. Use a t-interval when the population standard deviation is unknown and you must estimate it from the sample, especially with small samples (n < 30). The t-distribution has heavier tails than the normal distribution, producing wider confidence intervals that account for additional uncertainty from estimating the standard deviation. As sample size increases, the t-distribution approaches the normal distribution, and z and t intervals become virtually identical above n = 100.
How does sample size affect the confidence interval width?
The margin of error is inversely proportional to the square root of the sample size: MOE = z * sigma / sqrt(n). This means quadrupling the sample size cuts the margin of error in half. For example, with sigma=10 at 95% confidence: n=25 gives MOE=3.92, n=100 gives MOE=1.96, n=400 gives MOE=0.98. This diminishing-returns relationship means that beyond a certain point, large increases in sample size yield small improvements in precision. Researchers use sample size calculators to find the minimum n needed for a desired margin of error, balancing precision against cost and feasibility.
What is the Wilson score interval for proportions?
The Wilson score interval is an improved method for computing confidence intervals for proportions, developed by Edwin Wilson in 1927. Unlike the standard Wald interval (p-hat +/- z*SE), the Wilson interval performs better when the sample size is small or the proportion is near 0 or 1. The Wald interval can produce impossible values (below 0 or above 1) and has poor coverage probability for extreme proportions. The Wilson interval is centered not at p-hat but at a value pulled slightly toward 0.5, and its width adjusts based on the estimated proportion. It is now recommended as the default method by many statisticians and is used in medical research and survey analysis.
How do I interpret overlapping confidence intervals?
A common misconception is that non-overlapping confidence intervals indicate a statistically significant difference. While non-overlap does imply significance, overlapping CIs do NOT necessarily mean the difference is non-significant. Two 95% CIs can overlap by as much as 25% of their width and still indicate a significant difference at the 0.05 level. This is because the CI for the difference between two means is not simply the overlap of individual CIs. To properly compare two groups, construct a CI for the difference (mean1 - mean2) and check if it contains zero. If zero is not in the interval, the difference is statistically significant at the corresponding alpha level.
What is the difference between the standard deviation and the standard error of the mean?
The standard deviation s describes how spread out the individual observations are, and it does not shrink as you collect more data. The standard error of the mean, s / sqrt(n), describes how precisely the sample mean estimates the population mean, and it does shrink as n grows. Confidence intervals for a mean are built from the standard error, not the standard deviation, which is why an interval can be narrow even when the underlying measurements vary widely.
Should I report a 90%, 95% or 99% confidence interval?
The confidence level sets the trade-off between coverage and width. The two-sided critical z values are 1.645, 1.960 and 2.576, so on identical data a 99% interval is about 1.31 times wider than a 95% interval and a 90% interval is about 16% narrower. Higher confidence buys a greater long-run capture rate at the cost of precision. Choose the level from your field's convention before you see the data, since picking it afterwards to make a result look decisive destroys the coverage claim.
How does a confidence interval relate to a hypothesis test?
They are two views of one calculation. A two-sided test at alpha = 0.05 rejects a candidate null value exactly when the 95% interval built from the same standard error excludes that value, so an interval for a difference that misses zero corresponds to p below 0.05. The interval carries more information, because it also shows the direction and magnitude of the effects still compatible with the data, whereas a p-value collapses all of that into a single number.
What sample size should I assume for a proportion when I have no pilot estimate?
Use p = 0.5, because the variance term p(1 - p) peaks at 0.25 there and therefore gives the most conservative requirement. Substituting into n = z^2 x p(1 - p) / MOE^2 for a 5 percentage-point margin at 95% confidence gives n = 3.8416 x 0.25 / 0.0025 = 384.16, so 385 respondents. If a pilot survey shows the proportion sits far from 0.5, plugging that value in lowers the required sample noticeably.
What do the degrees of freedom mean in a t-interval?
Degrees of freedom equal n - 1 for a one-sample interval, because one piece of information is spent estimating the sample mean before the residual spread can be measured. Fewer degrees of freedom mean the sample standard deviation is itself a shakier estimate, so the critical value inflates. At 95% confidence it is 12.706 with 1 degree of freedom, 2.262 with 9 and 2.045 with 29, converging on the z value of 1.960 as the sample grows.
References
Background & Theory
History
Reviewed for accuracy by Daniel Agrici, Founder & Lead Developer ยท Editorial policy
Related Calculators
๐Confidence Interval Builder
Calculate confidence intervals for means and proportions with visualization
๐งฎAlpaca Gestation Calculator
Calculate alpaca gestation with inputs, formulas, and instant results.
๐งฎCat Pregnancy Calculator โ Due Date & Gestation
Calculate cat pregnancy with inputs, formulas, and instant results.
๐งฎCow Gestation Calculator
Calculate cow gestation with inputs, formulas, and instant results.
๐งฎDog Pregnancy Calculator: Due Date by Breed
Calculate dog pregnancy with inputs, formulas, and instant results.
๐งฎGoat Gestation Calculator
Calculate goat gestation with inputs, formulas, and instant results.
๐งฎGuinea Pig Pregnancy Calculator โ Due Date
Calculate guinea pig pregnancy with inputs, formulas, and instant results.
๐งฎLlama Gestation Calculator
Calculate llama gestation with inputs, formulas, and instant results.