← Math|47 of 100
Statistics

Confidence Intervals

Master confidence intervals for means and proportions, margin of error, sample size determination, bootstrap methods, and applications in A/B testing and AI/ML.

📂 Estimation📖 Lesson 47 of 100🎓 Free Course

Advertisement

Confidence Intervals

â„šī¸ Why It Matters

Point estimates hide how uncertain that estimate is. A confidence interval provides a range of plausible values for an unknown population parameter, along with a measure of how confident we are that the interval captures the true value. Without CIs, every estimate looks equally trustworthy, whether it comes from 5 samples or 5,000. Confidence intervals are the backbone of scientific reporting, clinical trials, political polling, and A/B testing. Every time you read "the effect was 3.2% with a 95% CI of [1.1%, 5.3%]", you are seeing a confidence interval at work.


Overview

A confidence interval is a range [L,U][L, U] computed from sample data such that, before observing data, P(L≤θ≤U)=1−αP(L \leq \theta \leq U) = 1 - \alpha. After observing data, we compute specific bounds and say we are 100(1−α)%100(1-\alpha)\% confident the interval contains θ\theta. The general structure is point estimate Âą critical value × standard error. For means with known ΃\sigma, use the z-interval. When ΃\sigma is unknown (almost always), use the t-interval which has heavier tails reflecting the additional uncertainty from estimating ΃\sigma. For proportions, the Wilson score interval is preferred over the basic Wald interval, especially when p^\hat{p} is near 0 or 1. Bootstrap CIs make no distributional assumptions and work for any statistic.


Key Concepts

General CI Structure

Point EstimateÂąCritical Value×Standard Error\text{Point Estimate} \pm \text{Critical Value} \times \text{Standard Error}

Here,

  • Point Estimate\text{Point Estimate}=Best guess for the parameter (e.g., sample mean)
  • Critical Value\text{Critical Value}=z-score or t-score for the desired confidence level
  • Standard Error\text{Standard Error}=Estimated standard deviation of the point estimate

Z-Interval (Known ΃)

xˉ±zÎą/2â‹…Īƒn\bar{x} \pm z_{\alpha/2} \cdot \frac{\sigma}{\sqrt{n}}

Here,

  • xˉ\bar{x}=Sample mean (point estimate of Îŧ)
  • zÎą/2z_{\alpha/2}=Critical value from standard Normal distribution
  • ΃\sigma=Known population standard deviation
  • nn=Sample size

T-Interval (Unknown ΃)

xˉ±tα/2,  n−1⋅sn\bar{x} \pm t_{\alpha/2,\; n-1} \cdot \frac{s}{\sqrt{n}}

Here,

  • tÎą/2,  n−1t_{\alpha/2,\; n-1}=Critical t-value with n-1 degrees of freedom
  • ss=Sample standard deviation (estimates ΃)

CI for Proportion

p^±zα/2⋅p^(1−p^)n\hat{p} \pm z_{\alpha/2} \cdot \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}

Here,

  • p^\hat{p}=Sample proportion
  • nn=Sample size

Margin of Error

ME=zÎą/2â‹…ĪƒnME = z_{\alpha/2} \cdot \frac{\sigma}{\sqrt{n}}

Here,

  • MEME=Half-width of the CI; maximum expected difference

Sample Size for Desired ME

n=(zÎą/2â‹…ĪƒE)2n = \left(\frac{z_{\alpha/2} \cdot \sigma}{E}\right)^2

Here,

  • EE=Desired margin of error

Common Critical Values

Confidence LevelÎą\alphazÎą/2z_{\alpha/2}tÎą/2,30t_{\alpha/2, 30}
90%0.101.6451.697
95%0.051.9602.042
99%0.012.5762.750

Factors Affecting CI Width

FactorEffect on WidthReason
Higher confidence levelWiderMust cover more of the sampling distribution
Larger sample sizeNarrowerStandard error decreases as 1/n1/\sqrt{n}
Larger variabilityWiderMore uncertainty about the parameter

Quick Example

📝T-Interval: Clinical Trial

A drug trial measures blood pressure reduction in 25 patients: xˉ=8.2\bar{x} = 8.2 mmHg, s=3.1s = 3.1 mmHg. 95% CI with df=24df = 24, t0.025,24=2.064t_{0.025, 24} = 2.064:

SE=3.125=0.62,ME=2.064×0.62=1.28SE = \frac{3.1}{\sqrt{25}} = 0.62, \quad ME = 2.064 \times 0.62 = 1.28
CI=8.2Âą1.28=[6.92,9.48]CI = 8.2 \pm 1.28 = [6.92, 9.48]

Since the entire interval is positive, the drug appears effective. If the interval included zero, we could not conclude the drug works.

📝Election Poll CI

Poll of 1,200 voters: 648 support Candidate A. p^=0.54\hat{p} = 0.54.

SE=0.54×0.461200=0.0144,ME=1.96×0.0144=0.0282SE = \sqrt{\frac{0.54 \times 0.46}{1200}} = 0.0144, \quad ME = 1.96 \times 0.0144 = 0.0282
CI=0.54Âą0.028=[0.512,0.568]CI = 0.54 \pm 0.028 = [0.512, 0.568]

The interval excludes 50%, so the lead is statistically significant at the 95% level.


Key Takeaways

📋Summary: Confidence Intervals

  • Structure: Point estimate Âą critical value × SE. Narrower CIs = more precise estimates.
  • Z vs T: Use z when ΃\sigma is known; use t when ΃\sigma is unknown (almost always). The t-distribution has heavier tails for small nn.
  • Wilson > Wald for proportions: Use Wilson score interval when p^\hat{p} is near 0 or 1 or nn is small.
  • To halve ME, quadruple nn: Since ME∝1/nME \propto 1/\sqrt{n}, precision improvement is expensive.
  • Bootstrap CIs: Resample with replacement, take percentiles. Works for any statistic without distributional assumptions.
  • Decision Rule: CI excludes null value → reject H0H_0 at the corresponding Îą\alpha.
  • Misinterpretation: A 95% CI does NOT mean "95% probability the parameter is in this interval." It means 95% of such intervals would capture the parameter in repeated sampling.
  • Bayesian Alternative: Credible intervals DO have the interpretation "95% probability the parameter is in this interval."

Deep Dive

For detailed explanations, worked examples, and Python implementations, explore the dedicated statistics lessons:

Confidence Intervals for Means

Confidence Intervals for Proportions

Margin of Error

  • Margin of Error — Factors affecting ME, the 1/n1/\sqrt{n} rate, and practical guidelines for study planning

Sample Size Determination

Bootstrap Methods

Related Topics

  • Central Limit Theorem — Foundation for why CIs work: the sampling distribution of the mean is approximately Normal
  • Point Estimation — MLE and the point estimates that CIs are built around
  • Hypothesis Testing — CIs and hypothesis tests are duals: same information, different format
  • t-Distribution — The heavier-tailed distribution used when ΃ is unknown
Lesson Progress47 / 100