Tetsuro KURITA
2005-10-06 09:46:17 UTC
The following code in "polyfit.m" never give the best fit data in the
least squares sense as described in document.
X = (x * ones (1, n+1)) .^ (ones (l, 1) * (n : -1 : 0));
p = X \ y;
This code do nothing to mimimize `sumsq (p(x(i)) - y(i))'.
I think this code should be modified as follows.
X = (x * ones (1, n+1)) .^ (ones (l, 1) * (n: -1 : 0))
W = X'*X
z = X'*y
p = inv(W)*z
I am using Octave 2.1.57 on MacOS X.
=======================================================
Tetsuro KURITA
E-mail: ***@mac.com
http://homepage.mac.com/tkurita/scriptfactory/
=======================================================
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
least squares sense as described in document.
X = (x * ones (1, n+1)) .^ (ones (l, 1) * (n : -1 : 0));
p = X \ y;
This code do nothing to mimimize `sumsq (p(x(i)) - y(i))'.
I think this code should be modified as follows.
X = (x * ones (1, n+1)) .^ (ones (l, 1) * (n: -1 : 0))
W = X'*X
z = X'*y
p = inv(W)*z
I am using Octave 2.1.57 on MacOS X.
=======================================================
Tetsuro KURITA
E-mail: ***@mac.com
http://homepage.mac.com/tkurita/scriptfactory/
=======================================================
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------