[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Problem of polyfit

**From**: |
Paul Kienzle |

**Subject**: |
Re: Problem of polyfit |

**Date**: |
Thu, 6 Oct 2005 06:08:35 -0400 |

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.
`
- Paul
-------------------------------------------------------------
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
-------------------------------------------------------------

**Problem of polyfit**, *Tetsuro KURITA*, `2005/10/06`
**Re: Problem of polyfit**,
*Paul Kienzle* **<=**
**Re: Problem of polyfit**, *Tetsuro KURITA*, `2005/10/06`
**Re: Problem of polyfit**, *Paul Kienzle*, `2005/10/06`
**Re: Problem of polyfit**, *Tetsuro KURITA*, `2005/10/06`
**Re: Problem of polyfit**, *Dmitri A. Sergatskov*, `2005/10/07`
**Re: Problem of polyfit**, *Tetsuro KURITA*, `2005/10/07`
**Re: Problem of polyfit**, *Fredrik Lingvall*, `2005/10/07`
**Re: Problem of polyfit**, *Tetsuro KURITA*, `2005/10/07`
**Re: Problem of polyfit**, *Paul Kienzle*, `2005/10/07`
**Re: Problem of polyfit**, *Fredrik Lingvall*, `2005/10/07`
**Re: Problem of polyfit**, *Paul Kienzle*, `2005/10/07`