def estimateAnomalyLikelihoods(anomalyScores,<EOL>averagingWindow=<NUM_LIT:10>,<EOL>skipRecords=<NUM_LIT:0>,<EOL>verbosity=<NUM_LIT:0>):
if verbosity > <NUM_LIT:1>:<EOL><INDENT>print("<STR_LIT>")<EOL>print("<STR_LIT>", len(anomalyScores))<EOL>print("<STR_LIT>", skipRecords)<EOL>print("<STR_LIT>", anomalyScores[<NUM_LIT:0>:min(<NUM_LIT:20>, len(anomalyScores))])<EOL><DEDENT>if len(anomalyScores) == <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>aggRecordList, historicalValues, total =  _anomalyScoreMovingAverage(<EOL>anomalyScores,<EOL>windowSize = averagingWindow,<EOL>verbosity = verbosity)<EOL>s = [r[<NUM_LIT:2>] for r in aggRecordList]<EOL>dataValues = numpy.array(s)<EOL>if len(aggRecordList) <= skipRecords:<EOL><INDENT>distributionParams = nullDistribution(verbosity = verbosity)<EOL><DEDENT>else:<EOL><INDENT>distributionParams = estimateNormal(dataValues[skipRecords:])<EOL>s = [r[<NUM_LIT:1>] for r in aggRecordList]<EOL>if all([isinstance(r[<NUM_LIT:1>], numbers.Number) for r in aggRecordList]):<EOL><INDENT>metricValues = numpy.array(s)<EOL>metricDistribution = estimateNormal(metricValues[skipRecords:],<EOL>performLowerBoundCheck=False)<EOL>if metricDistribution["<STR_LIT>"] < <NUM_LIT>:<EOL><INDENT>distributionParams = nullDistribution(verbosity = verbosity)<EOL><DEDENT><DEDENT><DEDENT>likelihoods = numpy.array(dataValues, dtype=float)<EOL>for i, s in enumerate(dataValues):<EOL><INDENT>likelihoods[i] = tailProbability(s, distributionParams)<EOL><DEDENT>filteredLikelihoods = numpy.array(<EOL>_filterLikelihoods(likelihoods) )<EOL>params = {<EOL>"<STR_LIT>":       distributionParams,<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": historicalValues,<EOL>"<STR_LIT>":            total,<EOL>"<STR_LIT>":       averagingWindow,<EOL>},<EOL>"<STR_LIT>":<EOL>list(likelihoods[-min(averagingWindow, len(likelihoods)):]),<EOL>}<EOL>if verbosity > <NUM_LIT:1>:<EOL><INDENT>print("<STR_LIT>")<EOL>print(params)<EOL>print("<STR_LIT>", len(likelihoods))<EOL>print("<STR_LIT>", (<EOL>filteredLikelihoods[<NUM_LIT:0>:min(<NUM_LIT:20>, len(filteredLikelihoods))] ))<EOL>print("<STR_LIT>")<EOL><DEDENT>return (filteredLikelihoods, aggRecordList, params)<EOL>
Given a series of anomaly scores, compute the likelihood for each score. This
function should be called once on a bunch of historical anomaly scores for an
initial estimate of the distribution. It should be called again every so often
(say every 50 records) to update the estimate.

:param anomalyScores: a list of records. Each record is a list with the
                      following three elements: [timestamp, value, score]

                      Example::

                          [datetime.datetime(2013, 8, 10, 23, 0), 6.0, 1.0]

                      For best results, the list should be between 1000
                      and 10,000 records
:param averagingWindow: integer number of records to average over
:param skipRecords: integer specifying number of records to skip when
                    estimating distributions. If skip records are >=
                    len(anomalyScores), a very broad distribution is returned
                    that makes everything pretty likely.
:param verbosity: integer controlling extent of printouts for debugging

                    0 = none
                    1 = occasional information
                    2 = print every record

:returns: 3-tuple consisting of:

          - likelihoods

            numpy array of likelihoods, one for each aggregated point

          - avgRecordList

            list of averaged input records

          - params

            a small JSON dict that contains the state of the estimator