Small normal sample mean confidence interval (source code)

= Small normal sample mean confidence interval
{title2=$\bar X\pm t_{1-\alpha/2,n-1}S/\sqrt n$}

Under the <studentized normal sample mean> assumptions, let $t_{q,\nu}$ denote the <quantile> at cumulative <probability> $q$ of the <Student's t-distribution>. For $0<\alpha<1$, rearranging the event $|T|\leq t_{1-\alpha/2,n-1}$ gives a <Student t confidence interval> for the unknown <mean> $\mu$ with exact <coverage probability> $1-\alpha$. <NIST and SEMATECH e-Handbook of Statistical Methods/1.3.5.2. Confidence Limits for the Mean>[NIST and SEMATECH e-Handbook of Statistical Methods; NIST/SEMATECH e-Handbook, Section 1.3.5.2: confidence limits for the mean, interval formula and repeated-sampling interpretation]{ref}

Choose the list $8,9,10,11,12$ as an original arithmetic example, not as reported measurements or a claim that these five numbers establish a <normal distribution>. If such values were obtained under the assumed <independent and identically distributed> <normal distribution> model with unknown $\sigma$, then
$$
n=5,\qquad\bar x=10,\qquad\sum_{i=1}^5(x_i-\bar x)^2=10,\qquad s^2=\frac{10}{4}=2.5,\qquad\frac{s}{\sqrt5}=\sqrt{0.5}.
$$
There are four <statistical degrees of freedom>. For a 95% <confidence interval>, $t_{0.975,4}=2.776445105\ldots$, so
$$
\bar x\pm t_{0.975,4}\frac{s}{\sqrt5}=10\pm1.963243161\ldots=[8.036756839\ldots,\ 11.963243161\ldots].
$$
Using the <standard normal quantile> $z_{0.975}=1.959963985\ldots$ with the same estimated <standard error> would give only $10\pm1.385903824\ldots$. That underestimates the correct margin by about 29.4%. Indeed its actual <coverage probability> under this <normal distribution> model is $\mathbb P(|t_4|\leq z_{0.975})\simeq0.8784$, rather than 0.95.

\Image[/student-t-small-sample-confidence-interval.png]
{title=Chosen five-value example: estimating the spread requires a wider t confidence interval}

The observations, the <sample mean> and the <confidence interval> all have different meanings. The bar estimates the population <mean>; it is not an interval intended to contain 95% of individual observations. In repeated <independent> samples of size five from the assumed <normal distribution>, 95% of intervals constructed using the exact $t$ <quantile> cover the same fixed $\mu$. This is not a 95% <posterior probability> that the fixed <statistical parameter> lies in this particular realized interval. Such a probability requires a separate <Bayesian inference> model.

For this four-degree case, the <cumulative distribution function> has an especially simple form:
$$
F_4(t)=\frac12+\frac34a-\frac14a^3,\qquad a=\frac{t}{\sqrt{4+t^2}}.
$$
One can check the formula by <differentiation>: $F_4'(t)=\frac38(1+t^2/4)^{-5/2}=f_4(t)$, with limits zero and one at the two ends of the <real line>. Solving the increasing equation $F_4(t)=0.975$ by the <bisection method> gives the <quantile> used above.