Confidence Interval of Mean

Learn, calculate, and compare the confidence interval of the mean using the classical and bootstrapped approaches.

SciPy is another very convenient library in the Python ecosystem for data science. It is a collection of mathematical algorithms and convenience functions built on NumPy. We can use stats.norm() from the library to accomplish this task of computing the confidence interval using the classical formula for means.

Classical approach

We have already inserted z-scores for the 95% confidence level in the formula above. Let's reconfirm the values of the z-score using the ppf module available in scipy.stats.norm(). We'll be using this to get percentiles for our confidence interval formula.

Get hands-on with 1400+ tech skills courses.