help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem of polyfit


From: Tetsuro KURITA
Subject: Problem of polyfit
Date: Thu, 6 Oct 2005 18:46:17 +0900

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: address@hidden
  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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]