Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Calculating Confidence Interval with Python
course content

Course Content

Learning Statistics with Python

Calculating Confidence Interval with PythonCalculating Confidence Interval with Python

If we are working with a small distribution (size less than or equal to 30) that approximates the normal distribution, we will use t-statistics.

How to calculate the confidence interval?

  • We use the t.interval() function from scipy.stats for the Student's T distribution.
  • As mentioned earlier, alpha represents the confidence level.
  • df stands for the number of degrees of freedom.
  • loc represents the mean.
  • sem represents the standard error of the sample.

Degrees of Freedom

Degrees of freedom are the number of independent information elements used to estimate a parameter.

The formula for degrees of freedom is N - 1, where N is the sample size.

Feel free to adjust the alpha parameter and observe the resulting changes.

Everything was clear?

Section 5. Chapter 6