Linear regression is orthogonal projection. Finding the best linear fit to data is the same as finding the closest point in a subspace to a given vector. The normal equation solves both.
Sample variance uses $m-1$ in the denominator (Bessel's correction). Sample standard deviation $\sigma_{\vec{a}} = \|\vec{m}\|/\sqrt{m-1}$.
Standardized data has zero mean and unit variance. Applied column-by-column to a matrix. Used in the design matrix $X$ for standardized regression. Division by $\sigma = 0$ fails when a column is constant.
The scalar weight $w$ minimizes $\|\vec{c} - w\vec{a}\|^2$. The error $\vec{e} = \vec{c} - \vec{p}$ is perpendicular to $\vec{a}$: verify $\vec{a}^T\vec{e} = 0$.
The projection matrix is $P = A(A^TA)^{-1}A^T$. Properties: $P^2 = P$ (idempotent), $P^T = P$ (symmetric). MATLAB shortcut: p = A*(A\c). The backslash solves the normal equation efficiently.
The error is in the orthogonal complement of the column space of $A$ (left null space). This is the residual in linear regression.
$w_1$ is the slope, $w_2$ is the intercept. The best-fit line always passes through the center point $(\bar{a}, \bar{c})$.
Single-parameter model. The data matrix $A = \vec{a}$ (just one column — no ones column). Normal equation is scalar: $(\vec{a}^T\vec{a})k = \vec{a}^T\vec{c}$.
Validation residuals are optimistic because the model was trained on similar data. Test residuals represent true generalization. Leave-one-out (LOO) is a special case with $K = m$.
p = A*(A\c)A\c solves the normal equation for weights $\hat{w}$, then A* projects back: $\vec{p} = A\hat{w}$.