2025-11-12

What is a Confidence Interval?

Let \(X_1,\dots,X_n\) be a sample from a population with mean \(\mu\).
If population standard deviation (\(\sigma\)) is known and the data is normal, a \(100(1-\alpha)\%\) CI for \(\mu\) is: \[ \bar{X} \;\pm\; z_{\alpha/2}\,\frac{\sigma}{\sqrt{n}}. \] If pop. standard deviation (\(\sigma\)) is unknown, replace \(\sigma\) with sample standard deviation (\(s\)) and use \(n-1\): \[ \bar{X} \;\pm\; t_{\alpha/2,\,n-1}\,\frac{s}{\sqrt{n}}. \]

Margin of Error

The margin of error is the size of the interval in which the true mean lies: \[ \text{ME} = \text{critical value} \times \text{standard error}. \] For a one-sample mean (unknown \(\sigma\)): \[ \text{ME} = t_{\alpha/2,\,n-1}\,\frac{s}{\sqrt{n}}. \]

Do confidence intervals actually capture the true mean?

How do confidence level and sample size affect Margin of Error?

Margin of Error as a function of size and confidence level

Example of Confidence Interval (95%)

For: \[ \ {n} = 60 \] \[ \ \(\alpha\) = .05 \] \[ \ \(\sigma\) = 4 \] \[ \ \(\mu\) = 12 \]

##    lower estimate    upper 
## 11.28121 12.09828 12.91536

Code Demo

ci_mean(rnorm(30, 100, 15), conf = 0.9)

## # A tibble: 1 × 7
##       n  mean    sd  conf lower upper    ME
##   <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1    30  101.  18.1   0.9  95.8  107.  5.61

Takeaways

  • Confidence Interval = Estimate ± ME; ME grows with higher confidence and shrinks with larger \(n\).
  • Use t (not z) when \(\sigma\) is unknown.
  • Visuals can help choose an \(n\) or a confidence level.