Skip to main content

Least Square

Linear Least Squares

prediction=y(x,w)=w0+w1x1++wdxd=w0+Σj=1dwjxjprediction=y(x,w)=w_0+w_1x_1+\cdots+w_dx_d=w_0+\Sigma^d_{j=1}w_jx_j E(w)=12Σn=1N(xnwtn)2=12(Xwt)(Xwt)\begin{align*} E(w)&=\frac{1}{2}\Sigma^N_{n=1}(x^\intercal_nw-t_n)^2\\ &=\frac{1}{2}(Xw-t)^\intercal(Xw-t) \end{align*}

EE is the loss function.

Solve minwE(w)min_wE(w)

W=(XX)1XtW^*=(X^\intercal X)^{-1}X^\intercal t

where

  • WW^* is the optimal weights
  • XX is the design matrix (data) (one input vector per row)
  • tt is the vector of target values

Polynomial Curve Fitting

y(x,w)=w0+w1x+w2x2++wMxM=Σj=0Mwjxjy(x,w)=w_0+w1x+w_2x^2+\cdots+w_Mx^M=\Sigma^M_{j=0}w_jx^j

Polynomial function is a nonlinear function of xx, but it's a linear function of the coefficients ww, thus it's still a linear model.

E(w)=12Σi=1N(y(xn,w)tn)2E(w)=\frac{1}{2}\Sigma^N_{i=1}(y(x_n,w)-t_n)^2