# How to correct calculate anomaly score in TM?

**URL:** <https://discourse.numenta.org/t/how-to-correct-calculate-anomaly-score-in-tm/7902>\
**Category:** Getting Started\
**Created:** [September 27, 2020, 11:21am UTC](https://discourse.numenta.org/t/how-to-correct-calculate-anomaly-score-in-tm/7902 "2020-09-27T11:21:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bizunow13](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/bizunow13/32/5286_2.png) [@bizunow13](https://discourse.numenta.org/u/bizunow13)\
**Post date:** [September 27, 2020, 11:21am UTC](https://discourse.numenta.org/t/how-to-correct-calculate-anomaly-score-in-tm/7902/1 "2020-09-27T11:21:31Z")

</div>

Hello!

Im seen that in all graphics with anomaly score values lay in 0.0-1.0 range. For example:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/numenta/original/2X/a/a35513518fdc60ea7e47836de11be2219e7d9513.jpeg)

Please, can you explain proper way to calculate anomaly score?

In my implementation i sometimes get values greater than one, it seems to me that this is not correct:

```
learn() {
  this.anomalyScore = 0
  for (const column of this.columns) {
    if (this.isColumnActive(column)) {
      if (this.isColumnPredicted(column)) {
        this.activatePredictedColumn(column)
      } else {
        this.burstColumn(column)
        ++this.anomalyScore
      }
    } else {
      if (this.isColumnPredicted(column)) {
        this.punishWrongPredictions(column)
        ++this.anomalyScore
      }
    }
  }
  this.anomalyScore /= this.spatialPooler.getMaxActiveColumns()
  this.anomalyScore = Math.min(this.anomalyScore, 1.0) // sometimes this.anomalyScore > 1.0
  console.log('anomaly score', this.anomalyScore)
}
```

---

<div class="post-metadata">

**Author:** ![sheiser1](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/sheiser1/32/766_2.png) [@sheiser1](https://discourse.numenta.org/u/sheiser1)\
**Post date:** [September 27, 2020, 11:20pm UTC](https://discourse.numenta.org/t/how-to-correct-calculate-anomaly-score-in-tm/7902/2 "2020-09-27T23:20:21Z")

</div>

> [@bizunow13](#):
>
> can you explain proper way to calculate anomaly score?

The anomaly score is simply the proportion of all columns which burst at the current time step.

So you can calculate it simply as:

(number of predicted active columns / number of active columns)

OR

1 - (number of bursted active columns / number of active columns)
