[SciPy-User] Question about scikits.timeseries.lib.moving_funcs.mov_average

Wes McKinney wesmckinn at gmail.com
Wed Jun 23 12:08:26 EDT 2010


On Wed, Jun 23, 2010 at 12:02 PM, Wes McKinney <wesmckinn at gmail.com> wrote:
> On Wed, Jun 23, 2010 at 11:59 AM, Andreas <lists at hilboll.de> wrote:
>> Hi, thanks for your input!
>>
>>> In [4]: arr
>>> Out[4]:
>>> array([  0.,   1.,   2.,   3.,   4.,   5.,   6.,   7.,   8.,   9.,  NaN,
>>>         NaN,  NaN,  NaN,  NaN,  15.,  16.,  17.,  18.,  19.])
>>>
>>> In [5]: rolling_mean(arr, 10, min_periods=1)
>>> Out[5]:
>>> array([  0. ,   0.5,   1. ,   1.5,   2. ,   2.5,   3. ,   3.5,   4. ,
>>>          4.5,   5. ,   5.5,   6. ,   6.5,   7. ,   9. ,  11. ,  13. ,
>>>         15. ,  17. ])
>>
>> Actually, this is exactly what I'm looking for. Well, almost. For my
>> application, I would need the window to be centered on the current value,
>> and be going only backwards from it. (I'm analyzing atmospheric
>> measurement data.)
>>
>> Any ideas how this can be done?
>>
>> Cheers,
>>
>> Andreas.
>>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User at scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>
> Could you clarify what you mean by "centered on" (i.e. at time T which
> data points are included relative to T)? I work mostly with financial
> data and there it only makes sense to include trailing observations--
> so the window at time T includes periods T back to T - window + 1.
>

Apologies, I see from your prior e-mail. In that case maybe it makes
sense to shift the data back by window / 2 periods and then take the
moving average?



More information about the SciPy-User mailing list