# Anomaly detection - calculation and number format

Additional information about how anomaly detection information is calculated, displayed, and controlled.

## Calculation of anomaly detection fields

The methods used for the calculation of anomaly detection fields are shown below.

- ACPU RollLm (ACPU Roll Limit)
- ACPU RollLm = (StdDev CPU * Toleration Level for Alerts + RollAv CPU)
- AElap RollLm (AElapsed Roll Limit)
- AElap RollLm = (StdDev Elapsed * Toleration Level for Alerts + RollAv Elapsed)
- AGetpgs RollLm (AGetpages Roll Limit)
- AGetpgs RollLm = (StdDev Getpages * Toleration Level for Alerts + RollAv Getpages)
- ECPU RollLm (ECPU Roll Limit)
- ECPU RollLm = (StdDev CPU * Toleration Level for Exceptions + RollAv CPU)
- EGetpgs RollLm (EGetpages Roll Limit)
- EGetpgs RollLm = (StdDev Getpages * Toleration Level for Exceptions + RollAv Getpages)

## Number format for Elapsed, CPU, and Getpage fields

The following number format applies to the anomaly detection fields as described below:

- Db2 Query Monitor displays only 6 digits after the decimal place for Elapsed fields (RollAv Elapsed, EElap RollLm, AElap RollLm). If values are smaller than 6 digits after the decimal place (.000001) then zeros are displayed in these fields.
- Db2 Query Monitor displays only 6 digits after the decimal place for CPU fields (RollAv CPU, ECPU RollLm, ACPU RollLm). If values are smaller than 6 digits after the decimal place (.000001) then zeros are displayed in these fields.
- Db2 Query Monitor displays only 2 digits after the decimal place for Getpages fields (RollAv Getpages, EGetpgs RollLm, AGetpgs RollLm). If values are smaller than 2 digits after the decimal place (.01) then zeros are displayed in these fields.

## Role of StdDev in the calculation of CPU Factor

Db2 Query Monitor uses 1e-06 precision for CPU and Elapsed display. Consequently, the calculating factor for StdDev<1.e-06 is not practical because initial values already have this precision. Db2 Query Monitor therefore shows N/A for cases where the CPU Factor statistical error might be too large.

The same situation exists with Getpages calculation except with the 1e-02 precision.

## Defining buckets for anomalies

The logic that Db2 Query Monitor uses to define the different buckets for anomalies includes the same list of fields as is used for metrics data (displayed on Operational Summaries panels).

If the same SQL statement occurs repeatedly in exceptions and appears as a false-positive conditions, then the SQL has different combinations of the fields and consequently occurs in different buckets.

To reduce the number of such exceptions, you can turn off OPTKEYS but be aware that there are fields in the list that are not controlled by OPTKEYS and therefore cannot be turned off