Studentized normal sample mean (source code)

= Studentized normal sample mean
{title2=$T=(\bar X-\mu)/(S/\sqrt n)\sim t_{n-1}$}

Suppose $X_1,\ldots,X_n$, $n\geq2$, are <independent and identically distributed> with <normal distribution> $N(\mu,\sigma^2)$, where the <mean> $\mu$ and <standard deviation> $\sigma>0$ are unknown. Define the <sample mean> and <sample variance> by
$$
\bar X=\frac1n\sum_{i=1}^nX_i,\qquad S^2=\frac1{n-1}\sum_{i=1}^n(X_i-\bar X)^2.
$$
Under these assumptions,
$$
Z=\frac{\sqrt n(\bar X-\mu)}{\sigma}\sim N(0,1),\qquad V=\frac{(n-1)S^2}{\sigma^2}\sim\chi^2_{n-1},\qquad Z\text{ and }V\text{ are independent}.
$$
Substitution gives the exact ratio
$$
\frac{Z}{\sqrt{V/(n-1)}}=\frac{\bar X-\mu}{S/\sqrt n}\sim t_{n-1}.
$$
The unknown $\sigma$ cancels. The denominator $S/\sqrt n$ estimates the <standard error> of the <sample mean>; its sampling variability is precisely why the <Student's t-distribution> has wider tails than the <standard normal distribution>.

The crucial <independence> has a geometric explanation. Apply an <orthogonal transformation> to the standardized observations $(X_i-\mu)/\sigma$, choosing its first coordinate along $(1,\ldots,1)/\sqrt n$. That coordinate is $Z$; the remaining $n-1$ coordinates are <independent> <standard normal random variables> whose squared sum is $V$. Their <joint probability density> factorizes because the transformation preserves the squared length. This also explains the loss of one <statistical degree of freedom> when estimating the <mean>. Uncorrelatedness alone would not establish the required <independence> for arbitrary data.

The result is exact for every $n\geq2$ under the stated <normal distribution> model. A small <sample size> by itself does not justify it: a sample from an arbitrary <probability distribution> need not have the displayed <chi-squared distribution> or the necessary <independence>.