[SciPy-user] moving average, moving standard deviation, etc...
Stefan van der Walt
stefan at sun.ac.za
Wed Dec 27 02:33:28 CST 2006
On Sun, Dec 24, 2006 at 10:53:04PM -0400, A. M. Archibald wrote:
> On 24/12/06, Matt Knox <mattknox_ca at hotmail.com> wrote:
> > Ok, thanks. So it sounds like there is no easy way to do this generally without
> > doing some looping in python (for the standard deviation anyway), or writing
> > some C code. I'm more interested in the general strategy for doing these kinds
> > of calculations than these specific examples themselves necessarily. Although
> > they are useful for making pretty charts sometimes.
> Fancy indexing will do the job, more or less.
> This is the general idea I was trying to get at:
> chunk = 10
> data = arange(10000)/10000.
> indices = arange(len(data)-chunk+1)[:,newaxis]+arange(chunk)[newaxis,:]
> data_chunks = data[indices]
> and so on...
> The only problem is that it expands your data rather a lot. Personally
> I wouldn't worry about that until my application was written. I
> posted, some time ago, a function that would allow the easy
> construction of data_chunks as a view of the original array, that is,
> with no data copying. (Sorry, I don't remember how to find the
More information about the SciPy-user