help-octave
[Top][All Lists]

## Re: Problem of polyfit

 From: Tetsuro KURITA Subject: Re: Problem of polyfit Date: Fri, 7 Oct 2005 11:39:37 +0900

```
```
wpolyfit gives a similar fit to polyfit but does a better job of estimating the uncertainty. In any case, the results are generally accurate to 10^-9 or better relative error.
```
```
wpolyfit show following warnning, and result is same to the on of polyfit.m .
```
```
warning: in /sw/share/octave/2.1.57/site/m/octave-forge/optim/wsolve.m near line 76, column 5:
```warning: matrix singular to machine precision, rcond = 1.73942e-56
warning: attempting to find minimum norm solution

```
If you have a dataset for which polyfit performs particularly poorly please post it to the list.
```
Following is an example which show that polyfit.m does not works well.

y = [2.720;
2.811;
2.899;
2.946;
2.940;
2.956;
2.914;
2.949;
2.897;
2.821;
2.736;
2.657;
2.565;
2.363;
2.251;
2.109;
2.024;
1.981;
1.996;
2.068;
2.132;
2.263;
2.408;
2.544;
2.689;
2.825;
2.901;
2.939;
2.932;
2.966;
3.027;
3.129]

x = [900058.30 ;
1000061.71;
1100054.15;
1200085.73;
1300026.64;
1400014.73;
1500007.74;
1600050.93;
1700013.05;
1800024.58;
1900039.38;
2000011.13;
2100062.61;
2200059.35;
2300035.86;
2400023.69;
2500051.17;
2600062.55;
2700001.99;
2800050.76;
2900066.95;
3000066.57;
3100061.96;
3200061.67;
3300070.35;
3400015.58;
3500041.39;
3600066.28;
3700009.04;
3800063.72;
3900001.42;
4000001.16]

p1 = polyfit(x,y,8);
y1 = polyval(p1,x);

gplot ([x,y]),([x,y1])

p2 = wpolyfit(x,y,8);
y2 = polyval(p2,x);
gplot ([x,y]),([x,y2])

=======================================================
Tetsuro KURITA
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
-------------------------------------------------------------

```