The OLS case

For ordinary least squares (OLS) we know that the optimal solution is

$$ \hat{\boldsymbol{\beta}}^{\mathrm{OLS}}=\left( \boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}. $$

Inserting the above values we obtain that

$$ \hat{\boldsymbol{\beta}}^{\mathrm{OLS}}=\begin{bmatrix}2 \\ 2\end{bmatrix}, $$

The code which implements this simpler case is presented after the discussion of Ridge and Lasso.