MATH566 Lesson 11: Least squares approximation

Overview

Motivation: data points might be affected by errors. The interpolation criterion yi=f(xi)=g(xi), i.e., exactly recover the function values is not appropriate.

>> 
m=100; x=linspace(0,1,m)';
>> 
c0=2; c1=3; z=c0+c1*x;  y=(z+rand(m,1)-0.5);
>> 
A=ones(m,2); A(:,2)=x(:); [Q,R]=qr(A); c = R \ (Q'*y); c'

( 1.9506 3.0310 )

>> 
w=A*c; plot(x,z,'k',x,y,'.r',x,w,'g');