Exponential moving sum in numpy / scipy?

I am looking for a function to compute an exponential moving sum in numpy or scipy. I want to avoid using python loops because they are very slow.

I have two series A [] and T []. T [i] is the timestamp A [i]. I determine the half-life of tau. Over a given time t, the exponential moving sum is the sum of all values ​​of A [i] that occur before t, with the weight exp (- (tT [i]) / tau) for each A [i].

Thanks a lot!

+4
source share
2 answers

Take a look at numpy.convolve . The exponential moving sum is a convolution.

+6
source

You can try to improve python loops by doing good β€œpractices” (for example, avoiding dots).

Perhaps you can program the function in C (in the "numpy library") and call it from python.

0
source

Source: https://habr.com/ru/post/1380215/


All Articles