[pymvpa] detrend(): why Legendre polynomials?

Per B. Sederberg persed at princeton.edu
Mon Mar 9 03:29:30 UTC 2009


howdy e:

sorry in advance for the lack of detail in my response, i'm writing
from my phone.

when detrending via a regression, you want to add in regressors that
follow the shape of the order polynomial you are trying to remove.  I
think the polyfit function is simply fitting a polynomial to your
data, which is a different thing.

what we do for the detrend regression is add in separate legendre
polynomials that match the length of each run and then keep anything
that they don't account for in the data.

spero che tutto e' bene in bel' italia!

ciao,
p

On 3/8/09, Emanuele Olivetti <emanuele at relativita.com> wrote:
> 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
>
>
> _______________________________________________
> Pkg-ExpPsy-PyMVPA mailing list
> Pkg-ExpPsy-PyMVPA at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/pkg-exppsy-pymvpa
>



More information about the Pkg-ExpPsy-PyMVPA mailing list