def _anomalyScoreMovingAverage(anomalyScores, windowSize=10, verbosity=0):
 historicalValues = []
 total = 0.0
 averagedRecordList = []
 for record in anomalyScores:
  if ((not isinstance(record, (list, tuple))) or (len(record) != 3)):
   if (verbosity >= 1):
    print ('Malformed record:', record)
   continue
  (avg, historicalValues, total) = MovingAverage.compute(historicalValues, total, record[2], windowSize)
  averagedRecordList.append([record[0], record[1], avg])
  if (verbosity > 2):
   print ('Aggregating input record:', record)
   print ('Result:', [record[0], record[1], avg])
 return (averagedRecordList, historicalValues, total)

def _anomalyScoreMovingAverage ( anomalyScores , windowSize = 10 , verbosity = 0 ) : historicalValues = [ ] total = 0.0 averagedRecordList = [ ] for record in anomalyScores : if ( ( not isinstance ( record , ( list , tuple ) ) ) or ( len ( record ) != 3 ) ) : if ( verbosity >= 1 ) : print ( 'Malformed record:' , record ) continue ( avg , historicalValues , total ) = MovingAverage . compute ( historicalValues , total , record [ 2 ] , windowSize ) averagedRecordList . append ( [ record [ 0 ] , record [ 1 ] , avg ] ) if ( verbosity > 2 ) : print ( 'Aggregating input record:' , record ) print ( 'Result:' , [ record [ 0 ] , record [ 1 ] , avg ] ) return ( averagedRecordList , historicalValues , total )
given a list of anomaly scores return a list of averaged records .