[Numpy-discussion] std(axis=1) memory footprint issues + moving avg / stddev

Rob Hooft rob at hooft.net
Sun Aug 27 02:46:40 EDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Torgil Svensson wrote:

> My original problem was to get an moving average and a moving standard
> deviation (120k rows and N=1000). For average I guess convolve should
> perform good, but is there anything smart for std()? For now I use ...
> 
>>>> moving_std=array([a[i:i+n].std() for i in range(len(a)-n)])
> 
> which seems to perform quite well.

You can always look for more fancy and unreadable solutions, but since
this one has the inner loop with a reasonable vector length (1000) coded
 in C, one can guess that the performance will be reasonable. I would
start looking for alternatives only if N drops significantly, say to <50.

Rob

- --
Rob W.W. Hooft  ||  rob at hooft.net  ||  http://www.hooft.net/people/rob/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE8T/QH7J/Cv8rb3QRAtutAKCikJ1qLbedU4pNl7ZohHCLEAWVKACgji9R
6evNgk6R68/JnimUs4OOd98=
=htbE
-----END PGP SIGNATURE-----




More information about the NumPy-Discussion mailing list