## fauxshaux 4 years ago How can I use the method of least squares to fit a line to the points { (0,0), (1,2), (2,1), (3,4) }?

1. druvidfae

the method of least squares gives rise to the entire concept of karl pearsons coefficient.Try doing some research on that subject.And then retry the question.

2. bimol12345

let the best fit line be y = ax + b then u using least square method "a" and "b" satisfies $(\sum_{1}^{4} x _{i} ^{2}).a + (\sum_{1}^{4} x _{i}).b = \sum_{1}^{4} x _{i} y _{i}$ $(\sum_{1}^{4} x _{i}).a + 4b = \sum_{1}^{4} y _{i}$ 14a + 7b = 16 7a + 4b = 7 on solving a= 15/7 , b = -2 => best fit y=(15/7)x -2

3. kh83

Write down the equations of the line (for all the points) in a form $Mx_{i}+N=y_{i}$ Then assemble the matrix equation: Ax = b, Where x is the vector of unknown line coeffiients x= [M,N] In general this equation cannot be solved unless vector b is in the column space of matrix A. Solve equation Ax = p instead, where p is projection of b on the column space of A. The error you make by taking the projection and not the real vector is e = b - p e is perpendicular to p and all vectors in column space of A so: $A ^{T}e=0$$A ^{T}(b-p) = 0$ $A ^{T}(b-Ax)=0$Solving the equation for unknow x gives: $x=(A ^{T}A)^{-1}A ^{T}b$which contains unknown line coefficients