# Confidence interval for the population mean

I learned that we can use $$[\hat{\mu} - 1.96 \hat{\sigma}/\sqrt{n}, \hat{\mu} + 1.96 \hat{\sigma}/\sqrt{n}]$$ as a confidence interval for the population mean, given a sample from the population, where $$\hat{\mu}$$ is the sample mean and $$\hat{\sigma}$$ is the sample SD and $$n$$ is the size of the sample.

However, I have a doubt about whether this is valid. I understand that the sample SD $$\hat{\sigma}$$ can be used as an estimator for the population SD $$\sigma$$, and that we can use the CLT to approximate the distribution of the sample mean as approximately normal. However, it seems that this confidence interval doesn't take into account the uncertainty in the population SD from drawing a sample (the population SD might be a bit larger or smaller than the sample SD), so intuitively, it seems like this formula might give me a confidence interval that is too narrow. So, is the formula above actually valid, and if so, why? Or is it not valid?

I prefer to avoid assuming that the population distribution is normal, though I'm also interested in the special case where the population is normally distributed.

The 95% confidence interval $$\bar X \pm 1.96\frac{\sigma}{\sqrt{n}}$$ for unknown $$\mu$$ is correct for normal data when the population standard deviation $$\sigma$$ is known. It is approximately correct for moderately large $$n,$$ when $$\sigma$$ is estimated by the sample standard deviation $$S.$$

However, you are correct to doubt this so-called 'z-interval' when $$\sigma$$ is estimated by $$S$$ and the sample size is small. Then the exact 95% CI for $$\mu$$ is given by $$\bar X \pm t^*\frac{S}{\sqrt{n}},$$ where $$\pm t^*$$ cut probability $$0.025 = 2.5\%$$ from the upper and lower tails, respectively, of Student's t distribution with $$\nu = n-1$$ degrees of freedom. [For example, if $$n = 10,$$ then $$t^* = 2.262;$$ computation in R.]

qt(.975, 9))
[1] 2.262157


At the 95% level in particular, $$t^* \approx 2$$ when $$n \ge 30,$$ so the z-interval gives pretty good results for $$n \ge 30.$$

qnorm(.975);  qt(.975,33)
[1] 1.959964
[1] 2.034515


More generally, for confidence level $$(1 - \alpha)\%.$$ there are other sample sizes $$n$$ at which $$t^*$$ is sufficiently near the $$z^*$$ that cuts probability $$\alpha/2$$ from the upper tail of the (symmetrical) standard normal distribution.

[For example, depending on ones degree of fussiness, something like $$n=400$$ might be large enough for a 98% CI; something like $$n=12$$ might be large enough for an 80% CI. But it is simpler just to use 't-intervals' whenever $$\sigma$$ is unknown and estimate by $$S.]$$

qnorm(.99);  qt(.99,400)
[1] 2.326348
[1] 2.335706

qnorm(.90);  qt(.90,11)
[1] 1.281552
[1] 1.36343


Note: You may sometimes see $$n = 30$$ given as a large enough sample size to pretend that the z-interval may be used even for non-normal data, and this can be very bad advice depending on the actual population distribution.

• Thank you for this explanation. Can you give me any intuition why this interval is approximately correct for moderately large $n$, when the population data is normally distributed? (from the first paragraph). Why don't we need to worry about uncertainty in our estimate of the population standard deviation?
– D.W.
Nov 2, 2020 at 3:33
• The z-interval is correct with large n because Student's t distribution approaches a normal distribution when the n is very large. Another way to think of it is that our confidence that the sample-based estimate is close to the population standard deviation increases as the sample size increases. (Those two sentences may sound different, but they are causally related.) Nov 2, 2020 at 7:12
• Note is a caution for non-normal data. For normal data, large sample, and 95% confidence, z-interval can be used as approximation instead of t-interval. But what's the fuss about? Why not just always use t-interval for normal data whenever $\sigma$ is estimated by $S.$ (And always use z-interval when \$\sigma is known.) Nov 2, 2020 at 8:11