#NEWLINE# def stddev_from_average( timeseries ) : #NEWLINE# #INDENT# '\n    A timeseries is anomalous if the absolute value of the average of the latest\n    three datapoint minus the moving average is greater than three standard\n    deviations of the average. This does not exponentially weight the MA and so\n    is better for detecting anomalies with respect to the entire series.\n    ' #NEWLINE# series = pandas . Series ( [ x [ 1 ] for x in timeseries ] ) #NEWLINE# mean = series . mean ( ) #NEWLINE# stdDev = series . std ( ) #NEWLINE# t = tail_avg ( timeseries ) #NEWLINE# return ( abs ( ( x - mean ) ) > ( 3 * stdDev ) )