[pymvpa] detrend(): why Legendre polynomials?
Emanuele Olivetti
emanuele at relativita.com
Sun Mar 8 23:18:05 UTC 2009
Howdy,
I'm still playing with polynomial detrend() and I'm wondering why
Legendr polynomials are used internally (see
mvpa/datasets/miscfx_sp.py) instead of standard polynomial fit, like
numpy.polyfit(). I'm fairly ignorant about numerical problems of
polynomial interpolation but could this be related to the "warning" in
the numpy.polyfit() docstring (which I partly understand)?
----
DISCLAIMER: Power series fits are full of pitfalls for the unwary
once the
degree of the fit becomes large or the interval of sample points is
badly
centered. The basic problem is that the powers x**n are generally a poor
basis for the functions on the sample interval with the result that the
Vandermonde matrix is ill conditioned and computation of the polynomial
values is sensitive to coefficient error. The quality of the
resulting fit
should be checked against the data whenever the condition number is
large,
as the quality of polynomial fits *can not* be taken for granted. If all
you want to do is draw a smooth curve through the y values and
polyfit is
not doing the job, try centering the sample range or look into
scipy.interpolate, which includes some nice spline fitting functions
that
may be of use.
----
Thanks in advance for any explanation,
Emanuele
More information about the Pkg-ExpPsy-PyMVPA
mailing list