---
# System prepended metadata

title: Derivation of least-squares estimation

---

# Derivation of least-squares estimation
$y = Xp$

$\min_p \|y - Xp\|_2^2$

$\|x\|_2 = \sqrt{x_1^2+x_2^2+\dots+x_n^2}$

$\|x\|_1 = |x_1|+|x_2|+\dots+|x_n|$

$\min_p \|y - Xp\|_2^2 + \lambda\|p\|_1$

$\min_p \dfrac{1}{2}(y - Xp)^\intercal (y - Xp)$

$\min_p \dfrac{1}{2}\left[y^\intercal y - y^\intercal Xp - (Xp)^\intercal y + (Xp)^\intercal Xp\right] \qquad a^\intercal b = b^\intercal a$

$\min_p \dfrac{1}{2}\left[y^\intercal y - 2y^\intercal Xp + (Xp)^\intercal Xp\right]$

$-\underbrace{y^\intercal X}_{a^\intercal}\underbrace p_x + p^\intercal X^\intercal Xp \qquad \dfrac{\text d (a^\intercal x)}{\text dx} = a$ $\qquad \dfrac{\text d x^\intercal A x)}{\text dx} = A + A^\intercal$

$-X^\intercal y +X^\intercal Xp=0$

$p=(X^\intercal X)^{-1} X^\intercal y$
