Learning Statistics with Python
Calculating Confidence Interval with Python
If we work with small distribution (the size is less or equal to 30) and the distribution approximates the normal, we will use t-statistics.
How to calculate confidence interval?
scipy.statswe use the
t.interval()function for the Student's T distribution.
- As it was before,
alphameans the confidence level.
dfis the number of degrees of freedom.
locis the mean.
semis the standard error of the sample.
Degrees of freedom
The degree of freedom is the number of independent information elements that go into estimating a parameter.
The formula is
N - 1, where
N is the sample size.
Try to change the
alpha parameter and observe the changes.