Why t distribution in confidence level for the mean? This is a basic question, but when I was asked about it I only could give a weak answer. That's why I am asking it here.
If we want to calculate the confidence level for the mean there is the formula:
$(\bar{x}-t_{n-1}s_{\bar{x}},\bar{x}+t_{n-1}s_{\bar{x}})$
I know that the t distribution comes in, when the variance is unkown and has to be estimated. So the assumption that sample means are normally distributed is violated. The sample means follow the t distribution. But why? For me there is a point missing or at least it is not intuitive to me.
 A: This explanation consists of two parts.


*

*The distribution of a t-statistic under the assumption of normality

*The construction of confidence intervals using pivotal quantities



*

*The distribution of a t-statistic under the assumption of normality
Consider $X_1, X_2, ..., X_n\stackrel{\text{iid}}{\sim}\text{N}(\mu,\sigma^2)$
Then $$Q=\frac{\bar{x}-\mu}{s_\bar{x}} = \frac{\bar{x}-\mu}{s/\sqrt{n}}$$ has a t-distribution with $n-1$ degrees of freedom.
I presume you are familiar with this part. (If not, we might need to explore that in another question.)

*The construction of confidence intervals using pivotal quantities
A pivotal quantity is a function of the data and parameter(s) whose distribution doesn't depend on the parameter(s)
Because of that, we can write down a probability statement relating to an interval for the pivotal quantity. 
So if we can write down a pivotal quantity involving the data and the parameter $\mu$ in the above iid normal situation, then we can write an interval for that pivotal quantity. From that we can back out an interval for the parameter.
In this case, the t-statistic above ($Q$) is a pivotal quantity; it is a function of the parameter $\mu$ and the data and its distribution is $t_{n-1}$, which doesn't depend on $\mu$. If $t_{1-\alpha/2}$ is the ${1-\alpha/2}$ quantile of a t-distribution (with $n-1$ d.f. being understood as given), then we can write $$P(-t_{1-\alpha/2}<Q<t_{1-\alpha/2})=1-\alpha$$
From there we can write $\frac{\bar{x}-\mu}{s_\bar{x}}$ for $Q$ and manipulate the probability statement above to obtain an expression giving an interval for $\mu$ with the desired coverage, which is the interval you stated.
