def stddev_from_moving_average(timeseries):
 series = pandas.Series([x[1] for x in timeseries])
 expAverage = pandas.stats.moments.ewma(series, com=50)
 stdDev = pandas.stats.moments.ewmstd(series, com=50)
 return (abs((series.iget((-1)) - expAverage.iget((-1)))) > (3 * stdDev.iget((-1))))

def stddev_from_moving_average ( timeseries ) : series = pandas . Series ( [ x [ 1 ] for x in timeseries ] ) expAverage = pandas . stats . moments . ewma ( series , com = 50 ) stdDev = pandas . stats . moments . ewmstd ( series , com = 50 ) return ( abs ( ( series . iget ( ( - 1 ) ) - expAverage . iget ( ( - 1 ) ) ) ) > ( 3 * stdDev . iget ( ( - 1 ) ) ) )
a timeseries is anomalous if the absolute value of the average of the latest three datapoint minus the moving average is greater than three standard deviations of the moving average .