[Top][All Lists]

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

Re: Problem of polyfit

From: Fredrik Lingvall
Subject: Re: Problem of polyfit
Date: Thu, 06 Oct 2005 12:51:10 +0200
User-agent: Mozilla Thunderbird 1.0.7 (X11/20050923)

Paul Kienzle wrote:

On Oct 6, 2005, at 5:46 AM, Tetsuro KURITA wrote:

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

 p = inv(X'*X)*X'*y
   = inv(X)*inv(X')*X'*y
   = inv(X)*I*y
   = inv(X)*y
   = X \ y

wpolyfit does the same with weighting on y, except that it uses QR decomposition to solve X \ y.


[U,D,V] = svd(X);

If you have singular values close to zero your in trouble.


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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