Statistics: Confidence interval for the mean(sigma not known)

This is part of the course “Probability Theory and Statistics for Programmers”.

Probability Theory and Statistics For Programmers

In the previous article, we look at how confidence interval for the mean can be found when we know the value of sigma. But more often we don’t have this value.


Let’s look at differences in inequalities for confidence intervals when we know sigma and when we don’t.

The differences are:

  1. we use sample sigma rather than population sigma
  2. we use t-value rather than z-value

We already knew how to find sample variance. But how to find t-value?

T-value have the same meaning as z-value, the only difference is that it uses t-distribution rather then normal distribution.

Let’s look at how T-distribution with different degrees of freedom compares with the normal distribution.

The first thing that catches your eye is that as more we increase the degree of freedom t-distribution become more close to normal distribution. And it has a good sense when you keep in mind the law of large numbers. For interest let’s build a chart that shows the difference between z-value and t-value for the fixed significance level of 0.05.

Now let’s try to make some simulations — generate normally distributed population, take a sample, find the sample mean and then find confidence interval. Degrees of freedom will be equal to sample size minus one.

Reach the next level of focus and productivity with




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store