help-octave
[Top][All Lists]
Advanced

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

Re: polyfit polynomial coefficiencts--don't understand output


From: Martin Helm
Subject: Re: polyfit polynomial coefficiencts--don't understand output
Date: Sat, 15 Oct 2011 01:53:43 +0200

Am Freitag, den 14.10.2011, 16:35 -0700 schrieb sameb: 
> Greetings all,
> 
> I'm trying to perform a linear regression analysis using polyfit and
> polyval. polyfit is not performing the way I expected. Here's a bit of
> code...
> 
> x = [0,1,2,3,4];
> y = x;
> [p,s,mu] = polyfit(x,y,1);
> [y1,dy] = polyval(p,x,s,mu);
> plot(x,y,'o',x,y1,'-')
> p 
> 
> and I'm thoroughly confused of the output p = [1.5,2]
> I thought it should be [1,0]. What's wrong? The plot looks correct.
> 
> Thanks,
> 
> Sam

"help polyfit" tells you when using 3 output paramters

     When the third output, MU, is present the coefficients, P, are
     associated with a polynomial in XHAT = (X-MU(1))/MU(2).  Where
     MU(1) = mean (X), and MU(2) = std (X).  This linear transformation
     of X improves the numerical stability of the fit.

So if you don't want that then just use one or two output parameters and
you will see the unchanged polynomial with [1 0]




reply via email to

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