What is the Confidence Interval in statistics with an example

A confidence interval is a statistical method where an estimate is measured from the observed data. A confidence interval gives a range of values. 

For example:

If someone asks the question, what is the probability of tomorrow’s temperature holding 42 degrees Celcius or more?

The Probability is 0

You can say it can be between 30 degrees Celcius to 47 degrees Celcius.


Formula of Confidence Interval:
  • CI = confidence interval
  •  = sample mean
  • z = confidence level value
  • s = sample standard deviation
  • n = sample size

Some sample doesn’t give the correct result. Point estimators are valuable, but they may cause errors because we’re not dealing with the entire population. All we’re doing is giving the best estimate. If the sample we use is unbiased, then the estimate is likely to be close to the true value of the population.

For Example, A Supermarket with 100 branches is thinking of starting a new product for its customer.

The profitability of the product depends on the average sales by the Supermarket.

A market research campaign is launched in which about 10 supermarkets participated in a pilot launch.

The average selling product by this Supermarket is 2021 and the standard deviation is 231

What can we say about the average product that will be sold after a full-fledged market launch?


Based on the survey and past data 

  •  = 2021
  • s = 231
  • n = 10
  • z= Confidence interval value that may be 80%, 95%, 99%
z value of confidence interval

First, calculate the s/√n

 s/√n = 231/√10 = 73.04

Formula link

 –z s/n x̄ +z s/n  

For a 95% confidence interval

 –z s/n x̄ +z s/n  

= 2021-(1.960) × 73.04 2021 + (1.960) × 73.04

= 1878 to 2164

For a 99% confidence interval

 –z s/n x̄ +z s/n  

= 2021-(2.576) × 73.04 2021 + (2.576) × 73.04

= 1833 to 2209

Confidence intervals are getting by performing the range and the error

For example, In the 95% interval of product launch, we get the range from 1833 to 2209, which means this is the average of many data.

What if we don’t know the Standard Deviation

We can replace the standard deviation with our best guess (point estimate) s, which is the standard deviation of the sample.

We can replace standard deviation with our best guess (point estimate) s, which is the standard deviation of the sample.

Confidence Interval in Python

print('Gain of 95% confidence interval of SBI is', np.round(sbi_ci, 4))

Output: Gain of 95% confidence interval of HDFC is [-0.0427 0.0427]

Leave a Comment