[SciPy-User] Boxcar smoothing of 1D data array...?

David Baddeley david_baddeley@yahoo.com...
Fri Jun 18 15:13:26 CDT 2010


Out of curiosity, are there any reasons other than performance (which might be moot if you have to implement the recursive filter as a python loop) for not using a convolution?

cheers,
David



________________________________
From: Sturla Molden <sturla@molden.no>
To: scipy-user@scipy.org
Sent: Fri, 18 June, 2010 11:22:45 PM
Subject: Re: [SciPy-User] Boxcar smoothing of 1D data array...?


Den 16.06.2010 02:26, skrev David Baddeley: 
> 
>Alternatively you could just use scipy.convolve with a tophat
>kernel ie (for a filter of length N & signal y):
>
>
>scipy.convolve(y, ones(N)/N)
>
>
>see the docs for scipy.convolve for more info (you might want to
>specify how it handles the ends, for example)
>
You should not use convolution for boxcar filtering. It can be solved
using a recursive filter, basically 

    y[n] = y[n-1] + x[n] - x[n-m]

then normalize y by 1/m.

Sturla



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100618/a259d8b2/attachment-0001.html 


More information about the SciPy-User mailing list