Solution (source code)

= Solution

Use the <normal linear model>
$$
\boxed{Y=X\beta+\varepsilon,\qquad \varepsilon\sim N_n(0,\sigma^2I_n).}
$$
Here $Y$ is the response <random vector>, $X$ is the known <design matrix>, $\beta\in\mathbb R^p$ contains the unknown <regression coefficients>, and $\sigma^2>0$ is the common error <variance>. Conditional on $X$, the errors have <normal distributions> and are <independent random variables>. Require $\operatorname{rank}X=p\leq n$ for <identifiability> of $\beta$ and invertibility of $X^TX$. Usually $n>p$ is needed to estimate the error <variance> from the <regression residuals>. An intercept, when included, is represented by a column of ones in $X$.