# What is the confidence interval?

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.

- Page: https://www.acalculator.org/statistics/confidence-interval-calculator
- JSON spec: https://www.acalculator.org/statistics/confidence-interval-calculator.json
- Version: 2bd0e5bbfbbc

## Default answer

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).

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| type | Interval for a | A mean (from a sample mean and standard deviation) or a proportion (from a count of successes). |
| mean | Sample mean (x̄) | The mean of your sample. |
| sd | Standard deviation | The sample standard deviation, or the population standard deviation σ when it is known. |
| method | Standard deviation is | The sample standard deviation (use the t distribution) or the known population standard deviation σ (use the normal z). |
| x | Successes (x) | How many in the sample have the trait, from 0 to the sample size. |
| n | Sample size (n) | How many observations are in the sample. |
| cl | Confidence level | How confident the interval is, in percent: 95 for a 95% confidence interval. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| margin | Margin of error (±) | The critical value times the standard error: the interval is the estimate plus or minus this. |
| lower | Lower limit | The estimate minus the margin of error. |
| upper | Upper limit | The estimate plus the margin of error. |
| estimate | Estimate | The sample mean, or the sample proportion p̂ = x ÷ n. |
| se | Standard error | s ÷ √n for a mean, or √(p̂(1 − p̂) ÷ n) for a proportion. |
| critical | Critical value | The t (n − 1 degrees of freedom) or z value with an upper tail of (1 − confidence) ÷ 2. |
| caution | Caution | Shown for a proportion with fewer than 5 successes or 5 failures, when the interval is rough. |

## 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.

## Assumptions

- 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

1. type = mean, mean = 68, sd = 3, method = t, n = 36, cl = 95% gives critical = 2.030108, margin = 1.015054, lower = 66.984946, upper = 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.
2. type = mean, mean = 68, sd = 3, method = z, n = 36, cl = 90% gives critical = 1.644854, margin = 0.822427, lower = 67.177573, upper = 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).
3. type = mean, mean = 9.26146, sd = 0.022789, method = t, n = 195, cl = 95% gives lower = 9.258241, upper = 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).
4. type = proportion, x = 421, n = 500, cl = 95% gives estimate = 0.842, lower = 0.81003, upper = 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).
5. type = proportion, x = 300, n = 500, cl = 90% gives estimate = 0.6, margin = 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).

## FAQ

### 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.

## Sources

- 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
- 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
- OpenStax, Introductory Statistics 2e, §8.3 A Population Proportion. https://openstax.org/books/introductory-statistics-2e/pages/8-3-a-population-proportion
