What is a confidence interval and how do you interpret it?
Learn what a confidence interval is, how to build one, and how to interpret 95% confidence correctly for data science and statistics interviews.
Expected Interview Answer
A confidence interval is a range of values, computed from sample data, that is likely to contain the true population parameter at a stated confidence level such as 95%.
It is built from a point estimate plus and minus a margin of error, where the margin depends on the standard error and a critical value from the sampling distribution. The correct interpretation is about the procedure: if we repeated the sampling many times, about 95% of the intervals produced would contain the true parameter. It is not correct to say there is a 95% probability that the one interval you have contains the parameter, because the parameter is fixed and the interval either contains it or does not.
- Quantifies uncertainty around an estimate
- Communicates precision, not just a single number
- Width shrinks with larger samples
- Supports decision-making with a plausible range
- Complements hypothesis testing
AI Mentor Explanation
Predicting a batter's final average from ten innings is like a confidence interval: you do not claim an exact 42.0, you say the true long-run average likely sits between 38 and 46. Watch more innings and that band tightens, because a larger sample narrows the uncertainty around your estimate of the real ability.
Step-by-Step Explanation
Step 1
Pick a confidence level
Choose how sure you want to be, commonly 90%, 95% or 99%, which sets the critical value.
Step 2
Compute the point estimate
Calculate the sample statistic, such as the sample mean or proportion, from your data.
Step 3
Find the standard error
Estimate the variability of the statistic, typically the sample standard deviation divided by the square root of n.
Step 4
Choose the critical value
Use a z or t value matching the confidence level and, for t, the degrees of freedom.
Step 5
Build the interval
Combine estimate plus and minus critical value times standard error to get the lower and upper bounds.
What Interviewer Expects
- Correct frequentist interpretation of the procedure
- Awareness that the parameter is fixed, not random
- Understanding how sample size affects width
- Knowledge of z versus t and when each applies
- Ability to distinguish confidence level from probability of one interval
Common Mistakes
- Saying there is a 95% probability the parameter is in this specific interval
- Confusing a confidence interval with a prediction interval
- Using z when the population standard deviation is unknown and n is small
- Ignoring assumptions such as random sampling or normality
- Thinking a wider interval is always worse regardless of confidence level
Best Answer (HR Friendly)
“A confidence interval is a range of likely values for something you are trying to measure across a whole population, based on a sample. Instead of giving one exact number, it says the true value is probably somewhere in this range, and a bigger sample makes the range tighter and more reliable.”
Code Example
import numpy as np
from scipy import stats
data = np.array([12, 15, 14, 10, 13, 16, 11, 14, 15, 12])
n = len(data)
mean = data.mean()
se = stats.sem(data) # standard error of the mean
# t critical value for 95% confidence, n-1 degrees of freedom
t_crit = stats.t.ppf(0.975, df=n - 1)
margin = t_crit * se
print(f"Mean: {mean:.2f}")
print(f"95% CI: ({mean - margin:.2f}, {mean + margin:.2f})")Follow-up Questions
- How does increasing the sample size change the interval width?
- What is the difference between a confidence interval and a prediction interval?
- When should you use a t distribution instead of a z distribution?
- How does a confidence interval relate to a two-sided hypothesis test?
- What is a Bayesian credible interval and how does it differ?
MCQ Practice
1. Which statement correctly interprets a 95% confidence interval?
The confidence level describes the long-run success rate of the procedure across repeated samples, not the probability for one fixed interval.
2. All else equal, increasing the sample size will generally:
A larger sample reduces the standard error, which shrinks the margin of error and narrows the interval.
3. You should use a t distribution instead of a z distribution when:
The t distribution accounts for the extra uncertainty of estimating the standard deviation from a small sample.
Flash Cards
What does a confidence interval estimate? — A range of plausible values for a population parameter, computed from sample data at a stated confidence level.
Correct interpretation of 95% confidence? — Across many repeated samples, about 95% of the intervals produced would contain the true parameter.
What widens a confidence interval? — Higher confidence level, greater data variability, and smaller sample size all increase the width.
z or t distribution? — Use z when the population standard deviation is known or n is large; use t when it is estimated from a small sample.
Margin of error formula — Critical value times the standard error of the estimate.
Continue Learning
Related Interview Questions
What is the Central Limit Theorem and why does it matter for data science?
medium
What is hypothesis testing and what are the null and alternative hypotheses?
medium
What is the difference between correlation and causation in data analysis?
easy
How Do You Decide the Sample Size an Experiment Needs?
medium