y = numpy.zeros(len(data))
for i in range(len(data)):
if i == 0:
y[i] = (1.0-dec) * data[i]
else:
y[i] = (1.0-dec) * data[i] + (dec*y[i-1])
y
So for example I have
data = np.array([100,200,300,400,500])
dec = 0.1
output:
array([ 90. , 189. , 288.9 , 388.89 , 488.889])
But for a huge dataset of data the "for" loop will take a lot of time to execute, so I was seeking help from someone that can we optimize it using some function from numpy.