Sample Confidence Interval- Statistical Estimation Guide
What Is a Confidence Interval, Anyway?
A confidence interval is a range of values that's likely to contain the true population parameter you're trying to estimate. That's it. It's not a probability range for your data—it's a statement about how reliable your estimate is.
Most people get this wrong. They think a 95% confidence interval means there's a 95% chance the true value falls within that range. That's not what it means. It means if you repeated your study many times, 95% of the intervals you'd calculate would contain the true value.
Big difference. Don't mix these up.
The Formula You Actually Need
The basic confidence interval formula is:
CI = x̄ ± (critical value × standard error)
Where:
- x̄ is your sample mean
- critical value comes from your chosen distribution (z for large samples, t for small ones)
- standard error = standard deviation / √n
For proportions, you swap the mean for the proportion and use a slightly different standard error calculation.
Z-Intervals vs t-Intervals: When to Use Which
This trips up a lot of people. Here's the rule:
- Use z-intervals when you know the population standard deviation, or when your sample size is large (typically n > 30)
- Use t-intervals when you don't know the population standard deviation and your sample is small
The t-distribution accounts for extra uncertainty when you're estimating both the mean and the spread from your sample. As your sample size grows, the t-distribution converges toward the z-distribution.
Which Critical Value Should You Use?
Your confidence level determines your critical value. Common levels:
- 90% confidence → z* = 1.645
- 95% confidence → z* = 1.96
- 99% confidence → z* = 2.576
For t-distributions, the critical value depends on both your confidence level and your degrees of freedom (n-1).
How to Calculate a Confidence Interval: Step by Step
Let's walk through a real example. Suppose you survey 50 people about their daily screen time. Your sample mean is 4.2 hours with a standard deviation of 1.8 hours. You want a 95% confidence interval.
Step 1: Check Your Conditions
- Is your sample random? ✓
- Is your sample size large enough? n=50, so yes (n > 30)
- Are individual observations independent? ✓
Step 2: Find Your Critical Value
Since n > 30, use z*. For 95% confidence, z* = 1.96.
Step 3: Calculate the Standard Error
SE = s / √n = 1.8 / √50 = 1.8 / 7.07 = 0.255
Step 4: Calculate the Margin of Error
ME = z* × SE = 1.96 × 0.255 = 0.50
Step 5: Build Your Interval
CI = x̄ ± ME = 4.2 ± 0.50 = (3.70, 4.70)
Your 95% confidence interval is 3.70 to 4.70 hours of daily screen time.
Common Mistakes That Will Wreck Your Interval
- Confusing confidence level with probability. Your interval either contains the true value or it doesn't. The 95% refers to your method's long-run success rate, not the probability for this specific interval.
- Ignoring sample size requirements. Small samples with unknown population standard deviation need t-intervals, not z-intervals.
- Using the wrong standard error. For proportions, the formula is different. Don't plug proportions into the mean formula.
- Forgetting to check independence. If your observations are related (clustered data, repeated measures), your interval will be too narrow.
- Misinterpreting wider intervals. A 99% interval is wider than a 95% interval. That's not a weakness—it's the cost of higher confidence.
Confidence Intervals for Different Parameters
The calculation changes depending on what you're estimating. Here's a quick comparison:
| Parameter | Formula | When to Use |
|---|---|---|
| Population mean (known σ) | x̄ ± z*(σ/√n) | n > 30 or known population SD |
| Population mean (unknown σ) | x̄ ± t*(s/√n) | n ≤ 30, unknown population SD |
| Population proportion | p̂ ± z*(√[p̂(1-p̂)/n]) | Categorical data, large n |
| Difference of means | (x̄₁ - x̄₂) ± z*√(σ₁²/n₁ + σ₂²/n₂) | Comparing two groups |
What Affects the Width of Your Interval?
Three things determine how wide your confidence interval will be:
- Confidence level: Higher confidence = wider interval. Going from 95% to 99% adds width at the cost of precision.
- Sample size: Larger samples = narrower intervals. Width is inversely proportional to √n, so quadrupling your sample only halves the width.
- Variability: More variation in your population = wider intervals. You can't control this, but you need to measure it accurately.
One-Tailed vs Two-Tailed Intervals
Most confidence intervals are two-tailed, meaning they give you both a lower and upper bound. Sometimes you only care about one direction—like testing if a new drug is better than a placebo. In that case, you use a one-tailed interval.
For a one-tailed 95% confidence interval, you use z* = 1.645 instead of 1.96. This gives you a slightly narrower interval on one side, but you've committed to only looking in one direction.
Don't switch between one-tailed and two-tailed after seeing your data. That's p-hacking, and it applies to intervals too.
What You Can and Can't Conclude
A confidence interval tells you:
- The precision of your estimate
- Whether a hypothesized value falls within your plausible range
- How much uncertainty remains after accounting for sampling variability
A confidence interval does NOT tell you:
- The probability the true value is in your interval
- That 95% of your data falls within the interval
- Whether your sample is representative
If your data is biased, your interval will be biased. Statistics can't fix bad sampling.
Getting Started with Your Own Calculations
You can calculate confidence intervals by hand, with a calculator, or in software. Here's what most people actually use:
- Excel/Google Sheets: Use CONFIDENCE.T() or CONFIDENCE.NORM() functions
- R: Use t.test() with conf.int = TRUE
- Python: Use scipy.stats.t.interval() or norm.interval()
- Online calculators: Fine for one-off calculations, but learn the formula first so you understand what you're doing
Whatever tool you use, verify your work manually for your first few calculations. It's easy to plug in the wrong number or misinterpret output.