[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: polyfit weirdness
From: |
Henry F. Mollet |
Subject: |
Re: polyfit weirdness |
Date: |
Thu, 13 Feb 2003 14:49:27 -0800 |
User-agent: |
Microsoft-Entourage/10.1.1.2418 |
Your commands produced exactly what Miguel calculated a little differently.
I'm using GNU Octave, version 2.1.35 (powerpc-apple-darwin6.2).
But please tell me if I'm fitting a polynomial of order 1 (= straight line)
thru the data and that my intercept (-1.49) and slope (4.2-15) appear in the
wrong order?
Henry
octave:1> l1 = 1e-9 * [ 578.45 545.88 435.87 404.71 365.26 ];
octave:2> v1 = [ 0.66 0.79 1.40 1.58 1.92 ];
octave:3> f1 = 299792458 ./ l1;
octave:4> [p1,cv1] = polyfit(f1,v1,1)
p1 =
4.1679e-15
-1.4948e+00
cv1 =
0.66528 0.79417 1.37189 1.59260 1.92606
on 2/12/03 4:57 AM, Miquel Cabanas at address@hidden wrote:
> hi,
>
> On Tue, Feb 11, 2003 at 02:08:37AM -0600, Scott Lamb wrote:
>>
>> So first I'm calling polyfit to get the trendline:
>>
>> l1 = 1e-9 * [ 578.45 545.88 435.87 404.71 365.26 ]
>> v1 = [ 0.66 0.79 1.40 1.58 1.92 ]
>> f1 = 299792458 ./ l1
>> [p1,cv1] = polyfit(f1,v1,1)
>>
>> ...and it doesn't return what I'd expect at all:
>
> I think we can narrow the problem to be related to the
> left-division in polyfit, could you try running (this is
> what polyfit does),
>
> n = 1;
> l = 5;
>
> x = [ 5.1827e+14 5.4919e+14 6.8780e+14 7.4076e+14 ...
> 8.2076e+14 ]';
>
> y = [ 0.66000 0.79000 1.40000 1.58000 1.92000 ]';
>
> X = (x * ones (1, n+1)) .^ (ones (l, 1) * (0 : n));
> p = X \ y;
> yf = X * p;
>
> In my working Octave I get
>
> p =
>
> -1.4948e+00
> 4.1680e-15
>
> and (estimated y-values)
>
> yf =
>
> 0.66529
> 0.79416
> 1.37188
> 1.59262
> 1.92605
>
> Also, what are eps, realmax and realmin in your versions? Again,
> mines are,
>
> eps = 2.2204e-16
> realmax = 1.7977e+308
> realmin = 2.2251e-308
>
>
> Miquel
-------------------------------------------------------------
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
-------------------------------------------------------------
Re: polyfit weirdness, Miquel Cabanas, 2003/02/12