f u t u r e ra
Forecasting methods

SUMMARY

Simple Smoothing

Methods

moving average

def ma_indices(source, L):
n = len(source)
start = ((L -1) // 2)
stop = n - (L - start -1)
a = []
for i in range(start,stop):
summation = 0
for j in range(L):
summation += source[i+j-start]
a.append(summation / L)
return a
def ma_exception(source, L):
a = []
for i in range(len(source)):
try:
summation = 0
for j in range(L):
summation += source[i+j]
a.append(sum / L)
except IndexError:
break
return a
def ma_stream(source, L):
a = []
summation = sum(source[0:L])
a.append(summation / L)
try:
for i in range(1,len(source)-1):
summation = summation + source[L+i-1] - source[i-1]
a.append(summation / L)
except IndexError:
pass
return a
BETA