[Numpy-discussion] Rolling window (moving average, moving std, and more)

Sebastian Haase seb.haase at gmail.com
Tue Jan 4 11:06:05 EST 2011


On Mon, Jan 3, 2011 at 5:32 PM, Erik Rigtorp <erik at rigtorp.com> wrote:
> On Mon, Jan 3, 2011 at 11:26, Eric Firing <efiring at hawaii.edu> wrote:
>> Instead of calculating statistics independently each time the window is
>> advanced one data point, the statistics are updated.  I have not done
>> any benchmarking, but I expect this approach to be quick.
>
> This might accumulate numerical errors. But could be fine for many applications.
>
>> The code is old; I have not tried to update it to take advantage of
>> cython's advances over pyrex.  If I were writing it now, I might not
>> bother with the C level at all; it could all be done in cython, probably
>> with no speed penalty, and maybe even with reduced overhead.
>>
>
> No doubt this would be faster, I just wanted to offer a general way to
> this in NumPy.
> _______________________________________________

BTW, some of these operations can be done using scipy's ndimage  - right ?
Any comments ?  How does the performance compare ?
ndimage might have more options regarding edge handling, or ?

Cheers,
Sebastian Haase



More information about the NumPy-Discussion mailing list