load polynomial_x_regression.mat
A = [x.^4 x.^3 x.^2 x ones(size(x))];
L = -y;
P = diag(p);

X = -inv(A'*P*A)*(A'*P*L)
V = A * X + L; 

sum(P*V)
A'*P*V

sigma = sqrt( V'*P*V / ( size(A)(1)-size(A)(2)) )
hold on
plot (x,y,'*');
plot(x,polyval(X,x),"-","linewidth",5)
hold off
pause

