#NEWLINE# def _movingAverage( data , n ) : #NEWLINE# #INDENT# 'Calculate the moving average from a time series.' #NEWLINE# out = np . cumsum ( data ) #NEWLINE# out [ n : ] = ( out [ n : ] - out [ : ( - n ) ] ) #NEWLINE# return ( out [ ( n - 1 ) : ] / n )