def mean_subtraction_cumulation(timeseries):
 series = pandas.Series([(x[1] if x[1] else 0) for x in timeseries])
 series = (series - series[0:(len(series) - 1)].mean())
 stdDev = series[0:(len(series) - 1)].std()
 expAverage = pandas.stats.moments.ewma(series, com=15)
 return (abs(series.iget((-1))) > (3 * stdDev))

def mean_subtraction_cumulation ( timeseries ) : series = pandas . Series ( [ ( x [ 1 ] if x [ 1 ] else 0 ) for x in timeseries ] ) series = ( series - series [ 0 : ( len ( series ) - 1 ) ] . mean ( ) ) stdDev = series [ 0 : ( len ( series ) - 1 ) ] . std ( ) expAverage = pandas . stats . moments . ewma ( series , com = 15 ) return ( abs ( series . iget ( ( - 1 ) ) ) > ( 3 * stdDev ) )
a timeseries is anomalous if the value of the next datapoint in the series is farther than three standard deviations out in cumulative terms after subtracting the mean from each data point .