[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #46126] Polyfit bug: Different polynomial coef
From: |
Pantxo Diribarne |
Subject: |
[Octave-bug-tracker] [bug #46126] Polyfit bug: Different polynomial coefficients when using optional output |
Date: |
Mon, 05 Oct 2015 10:02:41 +0000 |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0 |
Update of bug #46126 (project octave):
Status: None => Works For Me
_______________________________________________________
Follow-up Comment #1:
Hi,
Looks like requesting the third coefficient changes the signification of the P
output, as written in the doc:
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 it must be used as following:
x = 1:100;
y = sin (2*pi*x/100) + 0.3*rand(1,100);
plot (x, y)
hold on
p = polyfit (x, y, 3); % normal polynomial coeffs.
plot (x, polyval (p, x), "-k")
[p, s, mu] = polyfit (x, y, 3); % modified polynomial coeffs.
xx = (x-mu(1))/mu(2);
plot (x, polyval (p, xx), "-m")
Can I close this report or do you think the documentation should be modified.
It was quite clear to me how to use modified polynomial coeffs though.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?46126>
_______________________________________________
Message posté via/par Savannah
http://savannah.gnu.org/