Menu

Confidence Intervals

Confidence Intervals

A confidence interval gives a range of plausible values for a population parameter rather than a single estimate.

Formula for a Mean

CI = x̄ ± z × (σ / √n)

  • x̄: the sample mean, the center of the interval.
  • z: the critical value for the chosen confidence level. It is 1.645 for 90%, 1.96 for 95% and 2.576 for 99%.
  • σ / √n: the standard error of the mean.
  • z × (σ / √n): the margin of error, how far the interval extends on each side.

When σ is unknown and the sample is small, we use the sample standard deviation s and replace z with a t value, which gives slightly wider intervals.

How to Read It

A 95% confidence level describes the method. If you repeated the sampling many times and built an interval each time, about 95% of those intervals would contain the true value.

It does not mean there is a 95% chance that the true value sits inside one particular interval. Higher confidence or a smaller sample both widen the interval.

Example: A sample of 100 orders has a mean value of $52, and the population standard deviation is $15. Build a 95% confidence interval.

  1. SE = 15 / √100 = 1.5
  2. Margin of error = 1.96 × 1.5 = 2.94
  3. CI = 52 ± 2.94, which gives (49.06, 55.94)

The true average order value is plausibly between $49.06 and $55.94.

from scipy import stats

stats.norm.interval(0.95, loc=52, scale=1.5)

Code Explanation:

  • 0.95 sets the confidence level.
  • loc=52 is the center of the interval, the sample mean.
  • scale=1.5 is the standard error.
  • The function returns the lower and upper limits, about (49.06, 55.94).

Probability and Statistics for Data Science

AP

Abhishek Pati



Learn via Video Course

Probability and Statistics for Data Science Logo

Probability and Statistics for Data Science

4 hrs



Get in Touch For Details