def histogram_bins(timeseries):
 series = scipy.array([x[1] for x in timeseries])
 t = tail_avg(timeseries)
 h = np.histogram(series, bins=15)
 bins = h[1]
 for (index, bin_size) in enumerate(h[0]):
  if (bin_size <= 20):
   if (index == 0):
    if (t <= bins[0]):
     return True
   elif ((t >= bins[index]) and (t < bins[(index + 1)])):
    return True
 return False

def histogram_bins ( timeseries ) : series = scipy . array ( [ x [ 1 ] for x in timeseries ] ) t = tail_avg ( timeseries ) h = np . histogram ( series , bins = 15 ) bins = h [ 1 ] for ( index , bin_size ) in enumerate ( h [ 0 ] ) : if ( bin_size <= 20 ) : if ( index == 0 ) : if ( t <= bins [ 0 ] ) : return True elif ( ( t >= bins [ index ] ) and ( t < bins [ ( index + 1 ) ] ) ) : return True return False
a timeseries is anomalous if the average of the last three datapoints falls into a histogram bin with less than 20 other datapoints returns: the size of the bin which contains the tail_avg .