Confidence Interval Calculator

Compute confidence intervals for means and proportions, with margin of error and critical z/t values shown.

📏 Confidence Interval Calculator
Sample Mean (x̄)
Standard Deviation (σ or s)
Sample Size (n)
Confidence Level
Number of Successes (x)
Sample Size (n)
Confidence Level

📏 What is a Confidence Interval?

A confidence interval (CI) is a range of values, calculated from sample data, that is likely to contain the true population parameter (such as a mean or proportion) with a specified level of confidence. Rather than giving a single point estimate, it quantifies the uncertainty inherent in sampling by providing an upper and lower bound around that estimate.

In practice, confidence intervals appear everywhere data-driven decisions are made. Clinical trials report drug efficacy as "reduced symptoms by 42% (95% CI: 35%–49%)." Political polls state "candidate leads with 48% support, margin of error ±3%, 95% confidence." Market research reports "average customer satisfaction score: 7.4 (90% CI: 7.1–7.7)." Each of these communicates both a best estimate and how precise that estimate is.

A common misconception is that a 95% CI means "there is a 95% probability the true value is inside this interval." In frequentist statistics, the true parameter is fixed (not random). The 95% refers to the method: if you drew 100 samples and calculated 100 intervals using this method, about 95 would contain the true parameter. Any single computed interval either does or does not contain it - probability no longer applies once you have the specific numbers.

This calculator computes CIs for two common situations: estimating a population mean (given sample mean, standard deviation, and n), and estimating a population proportion (given successes and n). Both modes display the margin of error, critical value, and standard error alongside the interval bounds.

📐 Formula

CI for Mean  =  x̄  ±  z* × (σ ÷ √n)
= sample mean
z* = critical value (1.645 for 90%, 1.96 for 95%, 2.576 for 99%)
σ = population or sample standard deviation
n = sample size
SE = σ ÷ √n  —  standard error of the mean
Example: x̄ = 50, σ = 10, n = 30, 95% CI: ± 1.96 × (10 ÷ √30) = ± 3.58 → [46.42, 53.58]
CI for Proportion  =  p̂  ±  z* × √(p̂(1−p̂) ÷ n)
= sample proportion = x ÷ n (successes ÷ sample size)
z* = critical value for chosen confidence level
SE = √(p̂(1−p̂) ÷ n)  —  standard error of the proportion
Example: 240 of 400 (p̂ = 0.60), 95% CI: ± 1.96 × √(0.60×0.40/400) = ± 0.048 → [55.2%, 64.8%]

📖 How to Use This Calculator

Steps

1
Select a mode - "Mean (μ)" for estimating a population average, or "Proportion (p)" for estimating a rate or percentage.
2
Enter your sample statistics - sample mean and standard deviation for the mean mode; number of successes and sample size for the proportion mode.
3
Set the confidence level - 90%, 95%, or 99% are the standard choices; use custom for any other level.
4
Read the results - the lower and upper bounds define your interval; the margin of error is half the interval width.

💡 Example Calculations

Example 1 — Mean: Student Test Scores

A class of 36 students scored a mean of 72 with SD = 9. Find the 95% CI for the population mean.

1
Standard error (SE) = σ / √n = 9 / √36 = 9 / 6 = 1.5.
2
Margin of error = z* × SE = 1.96 × 1.5 = 2.94.
3
CI = 72 ± 2.94 → [69.06, 74.94].
95% CI: [69.06, 74.94]
Try this example →

Example 2 — Proportion: Election Poll

600 of 1,000 polled voters support a candidate. Find the 95% CI for the true proportion.

1
p̂ = 600 / 1000 = 0.60.
2
SE = √(0.60 × 0.40 / 1000) = √(0.00024) = 0.01549.
3
Margin of error = 1.96 × 0.01549 = 0.0304 (about ±3%).
4
CI = [0.60 − 0.0304, 0.60 + 0.0304] = [56.96%, 63.04%].
95% CI: [56.96%, 63.04%]
Try this example →

Example 3 — Mean at 99% Confidence

A factory measures 50 items: mean weight = 500 g, SD = 15 g. Find the 99% CI.

1
SE = 15 / √50 = 15 / 7.071 = 2.121 g.
2
Margin of error = 2.576 × 2.121 = 5.46 g.
3
99% CI = [500 − 5.46, 500 + 5.46] = [494.54 g, 505.46 g].
99% CI: [494.54 g, 505.46 g]
Try this example →

❓ Frequently Asked Questions

What is a confidence interval in statistics?+
A confidence interval (CI) is a range of values constructed from sample data that is likely to contain the true population parameter. A 95% CI means that if the study were repeated 100 times with different samples, approximately 95 of the 100 resulting intervals would contain the true population mean or proportion. It is NOT the probability that the true parameter lies in any single interval - once computed, the interval either contains the parameter or it does not.
What is the formula for a confidence interval for the mean?+
CI = x̄ ± z* × (σ / √n), where x̄ is the sample mean, z* is the critical value for your confidence level (1.96 for 95%), σ is the standard deviation, and n is the sample size. The term z* × (σ / √n) is the margin of error. When σ is unknown and n < 30, use the t-distribution critical value t* with n−1 degrees of freedom instead of z*.
What critical z-value is used for a 95% confidence interval?+
The critical value for 95% CI is z* = 1.96. For 90% CI: z* = 1.645. For 99% CI: z* = 2.576. These values come from the standard normal distribution - for 95%, you find the z-score such that 95% of the area lies between −z and +z (leaving 2.5% in each tail). These are the most commonly used values in research and quality control.
How do I calculate a confidence interval for a proportion?+
CI = p̂ ± z* × √(p̂(1−p̂)/n), where p̂ = successes/n is the sample proportion, z* is the critical value, and n is the sample size. For 240 of 400 people (p̂ = 0.60) at 95% CI: margin = 1.96 × √(0.60 × 0.40 / 400) = 1.96 × 0.0245 = 0.048. The CI is [0.552, 0.648], or about 55.2% to 64.8%.
How does sample size affect confidence interval width?+
The margin of error is proportional to 1/√n. Doubling the sample size reduces the margin of error by a factor of √2 (about 29%). To halve the margin of error, you need 4× the sample size. This relationship means there are diminishing returns to increasing sample size - going from n=100 to n=400 halves the margin; going from n=400 to n=1600 halves it again.
When should I use the t-distribution instead of z-distribution?+
Use the t-distribution when the population standard deviation σ is unknown and the sample size n < 30. The t-distribution has heavier tails than the normal distribution, producing wider confidence intervals that account for the additional uncertainty from estimating σ with the sample standard deviation s. For n ≥ 30, the t- and z-distributions give nearly identical results, so z is used for simplicity.
What is the margin of error?+
The margin of error (MoE) is the half-width of the confidence interval: MoE = z* × SE. If a poll reports "48% support, ±3%", the ±3% is the margin of error. The full 95% CI would be [45%, 51%]. A smaller margin of error means a more precise estimate, achieved through a larger sample size, a smaller standard deviation, or by accepting a lower confidence level.
What sample size do I need for a 3% margin of error?+
For a proportion at 95% confidence using p̂ = 0.5 (worst case): n = z*² × p̂(1−p̂) / MoE² = 1.96² × 0.25 / 0.03² = 3.8416 × 0.25 / 0.0009 ≈ 1,068. This is why most national polls use samples of about 1,000–1,100 - it achieves approximately ±3% margin at 95% confidence, which is considered sufficient for most practical purposes.
What is the difference between confidence interval and prediction interval?+
A confidence interval estimates where the population mean lies. A prediction interval estimates where a single future individual observation will fall - always wider than the CI because it must account for both the uncertainty in estimating the mean and the natural variability of individual observations. A CI for mean height might be [175 cm, 177 cm], while a prediction interval for one person's height might be [158 cm, 194 cm].
Can a confidence interval be wrong?+
Yes - that is the point. A 95% CI will fail to contain the true parameter approximately 5% of the time, by design. This is not a flaw; it is a trade-off. If you need fewer failures, use a higher confidence level (99%), but accept a wider interval. If you conduct many independent studies, about one in twenty 95% CIs will not contain the true parameter even with perfect methodology.

What is a confidence interval in statistics?

A confidence interval (CI) is a range of values constructed from sample data that is likely to contain the true population parameter. A 95% CI means that if the study were repeated 100 times with different samples, approximately 95 of the 100 resulting intervals would contain the true population mean or proportion. It is NOT the probability that the true parameter lies in any single interval - once computed, the interval either contains the parameter or it does not.

What is the formula for a confidence interval for the mean?

CI = x̄ ± z* × (σ / √n), where x̄ is the sample mean, z* is the critical value for your confidence level (1.96 for 95%), σ is the population standard deviation, and n is the sample size. The term z* × (σ / √n) is the margin of error. When σ is unknown (the usual case), replace z* with the t* critical value from the t-distribution with n−1 degrees of freedom.

What is the 95% confidence interval z-score?

The critical value for a 95% confidence interval is z* = 1.96 (from the standard normal distribution). This means 95% of the area under the normal curve falls within ±1.96 standard deviations of the mean. For 90% CI, z* = 1.645; for 99% CI, z* = 2.576. These values come from the inverse of the normal CDF at (1 + confidence level) / 2.

How do I calculate a confidence interval for a proportion?

CI = p̂ ± z* × √(p̂(1−p̂)/n), where p̂ is the sample proportion (successes/n), z* is the critical value, and n is the sample size. For example, if 240 of 400 people (p̂ = 0.60) prefer a product at 95% CI: margin = 1.96 × √(0.60 × 0.40 / 400) = 1.96 × 0.0245 = 0.048. The CI is [0.552, 0.648], or roughly 55.2% to 64.8%.

What does it mean to be 95% confident?

Being 95% confident means the procedure used to construct the interval captures the true parameter 95% of the time across repeated samples. It describes the reliability of the method, not the probability of any single interval. Once you calculate a specific interval like [4.2, 5.8], that interval either contains the true mean or it doesn't - there is no probability attached to a fixed, computed interval.

How does sample size affect the confidence interval width?

The margin of error is proportional to 1/√n. To halve the margin of error, you need 4 times the sample size. To reduce it by one-third, you need 9 times as many observations. This is why large-scale surveys (n = 1,000+) can achieve margins of error below ±3%, while small studies (n = 25) may have margins of ±20% or more at the same confidence level.

When should I use z-distribution vs t-distribution for confidence intervals?

Use the z-distribution (standard normal) when: (1) the population standard deviation σ is known, or (2) the sample size n ≥ 30 (by the Central Limit Theorem, the sampling distribution is approximately normal). Use the t-distribution when σ is unknown and n < 30. The t-distribution has heavier tails, producing wider intervals that account for the additional uncertainty from estimating σ using the sample standard deviation s.

What is the margin of error?

The margin of error (MoE) is the half-width of the confidence interval: MoE = z* × SE, where SE is the standard error (σ/√n for means, √(p̂(1−p̂)/n) for proportions). If a poll reports a candidate at 48% ± 3%, the 3% is the margin of error at whatever confidence level the poll used (typically 95%). The full CI would then be [45%, 51%].

How does confidence level affect the interval width?

Higher confidence levels produce wider intervals. At 90% CI, z* = 1.645; at 95% CI, z* = 1.96; at 99% CI, z* = 2.576. A 99% CI is about 31% wider than a 95% CI (ratio = 2.576/1.96 ≈ 1.31). The tradeoff is precision vs. certainty: a 99% CI is more likely to contain the true parameter but provides a less precise estimate of its location.

What is the difference between confidence interval and prediction interval?

A confidence interval estimates where the true population mean lies. A prediction interval estimates where a single future observation will fall - always wider than the CI. For example, a CI might say the average height of men is [175.2 cm, 176.8 cm], while a prediction interval for one man's height might be [158 cm, 194 cm]. Use CI to estimate parameters; use prediction intervals to forecast individual observations.

What sample size is needed for a given margin of error?

Rearranging the margin of error formula: n = (z* × σ / MoE)². For proportions: n = z*² × p̂(1−p̂) / MoE². To achieve a 3% margin of error at 95% confidence for a proportion, using p̂ = 0.5 (worst case): n = 1.96² × 0.25 / 0.03² = 3.8416 × 0.25 / 0.0009 ≈ 1,068 observations.