Introduction The relation between two numbers may be defined by
Each (x,y) pair we may paint as a point in a coordinate system. Then we may search for the best fitting polynomial. Note: a polynomial degree n is: ......y = c0+c1x+c2x2+........+cnxn please look at the figure above:painted are points (x1,y1)................and asked is the best fitting polynomial degree 1 through these points. "Best fitting" means, that the sum of the squared differences for each point is minimal. These differences are painted as dotted lines in the figure. The applied "Least Squares" method to find the best fitting polynomial is a nice application of linear algebra. My equation grapher Graphics-Explorer uses this method, the degree may be 0 to 7. The Least Squares method Given are points (x1,y1) , (x2,y2)...(xn , yn) requested: a polynomial degree m, y = c0 + c1x + c2x2 + ... + cmxm through these points having the minimal deviation. If all points are exactly on the the polynomial, so m+1 = n, we have:
y2 = c0 + c1x2 + c2x22 + ... + cmx2m ............. ............. yn = c0 + c1xn + c2xn2 + ... + cmxnm
or shorter: y = M . c
So, we look for c , where || y - M . c || is minimal. this will be the case if the difference vector is perpendicular to the column space of M. The inner product is zero in this case.
(ct Mt) (y - M c) = 0 ct ( Mt ( y - M c)) = 0 ct ( Mt y - Mt M c ) = 0 so: Mt y - Mt M c = 0 Mt M c = Mt y (Mt M)-1Mt M c = (Mt M)-1Mt y c = (Mt M)-1 Mt y 1. Mt means matrix M transposed, mirrored in it's diagonal, so writing the rows as columns. if
rule: ( A B)t = BtAt 3. The inner product of two vectors a en b may be written as at.b 4. In the case of linear regression, where m = 1 and c =[b,a] .......{because the line has the equation y = b + ax..} this is true:
Mt =
b
See formula's ....1) and ...........2) Example Find the least square straight line through points.........(0,1) (1,3) (2,4) en (3,4)
M t =
M t M =
(M t M) −1 = 0 , 1
c = 0 ,
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||