---
title: Use the Anomaly Detection Function
slug: manufacturing-connect-edge-v2/use-the-anomaly-detection-function
docTags: 
createdAt: 2024-05-24T20:18:43.067Z
---

The Anomaly Detection function applies the three-sigma rule to identify outliers by comparing data points against a dynamic threshold of standard deviations from the mean, allowing for real-time adjustment to emerging patterns.

This function operates by maintaining a rolling window of data, calculating the average and standard deviation within this window, and flagging values that deviate beyond the user-defined standard deviation range as anomalies.

# User Scenario

Review the following scenario for the anomaly detection processor function. Then, using an input processor, you will simulate PLC data and detect anomalies from the window of generated values.

In a large-scale manufacturing factory, the Anomaly Detection function is used to monitor the machine's temperatures. It calculates a moving average and standard deviation of temperature readings, flagging any readings that significantly deviate as potential cooling system failures. By defining the number of standard deviations from the average as the threshold for normal operation, factory engineers can quickly identify and respond to overheating risks, ensuring site reliability and uptime.&#x20;

# Step 1: Add a Device

Follow the steps to [Connect a Device](docId\:SqalV8ImyZmn8xA-56gno) and configure the following parameters:

- **Device Type**: Simulator
- **Driver Name**: Generator
- **Enable Alias Topics**: Select the checkbox.&#x20;

# Step 2: Add Tags

After connecting the device, add the following tag. See [Add Tags](docId:-5nFrBQ-uriWOY3GACnPt) to learn more.&#x20;

## Tag 1: input1

- **Name**: Select **S - Random value generator**
- **Value Type:** Select **float64**
- **Polling Interval**: Enter **1**
- **Tag Name**: Enter **input1**
- **Min\_value**: Enter **1**
- **Max\_value**: Enter **50**

# Step 3: Create Analytics Flow

You can now create the analytics flows using data from the device and tag you previously created.&#x20;

**To create an analytics flow with the Anomaly Detection Processor function:**

1. In Manufacturing Connect Edge, navigate to **Analytics**.&#x20;
2. On the analytics canvas, click **Add processor**.&#x20;
   The *Create a processor&#x20;*&#x64;ialog box displays.
   ![](https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/UGDbNL-imN_gysIjdhuX8_image.png "The Add processor option")
3. Select **DataHub Subscribe**.
4. In the *Topic&#x20;*&#x66;ield, click the **Search&#x20;**&#x69;con, select the device you previously created, and then select the alias topic for the **input1&#x20;**&#x74;ag.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/gavPZ9Wa_vzsgK8VuCBB__image.png" size="80" width="1141" height="571" position="center" caption="Create a Processor dialog box" showCaption="true"}
5. Click **Save**.
6. Click **Add processor** again and select the **Anomaly Detection&#x20;**&#x70;rocessor.
   The following information defines this function:
   - **Window Size:** Enter a value that represents the range to observe before making each prediction. For this example, we input a value of **100**.
   - **Deviations:&#x20;**&#x45;nter the number of standard deviations that would be considered normal, making everything outside that definition anomalous data. For this example, we input a value of **3**.
   - **Topic Reset:** Enable this option to reset the function on topic change.
   - **Control Chart Mode:&#x20;**&#x49;f this option is enabled, there will be no modifications done to the moving window before calculation.
   - Click **Save**.
     ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/9z7yLif1ZkiJKE8ZF9ysg_image.png" size="80" width="1145" height="775" position="center" caption="Edit a Processor dialog box" showCaption="true"}
7. Connect the *DataHub Subscribe* processor (tag: *input1*) to the *Anomaly Detection&#x20;*&#x70;rocessor with a wire and use the **events&#x20;**&#x63;onnection.
8. On the analytics canvas, click **Save**.
   The configured analytics flows should look like the following:&#x20;
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/U-pUmpdAWMaLbcYhlIc4k_image.png" size="80" width="743" height="290" position="center" caption="Completed Flows Canvas" showCaption="true"}

# Step 4: View Output of Processor

Click the **View&#x20;**&#x69;con in the *Anomaly Detection&#x20;*&#x70;rocessor to view the output values.

The output describes a situation where the current value of **1.86&#x20;**&#x69;s well above the lower limit of **0.13&#x20;**&#x61;nd below the upper limit of approximately **2.33**, suggesting no anomaly is detected at this timestamp within the moving average of **1.23** and a standard deviation of **0.36**.

![](https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/h6Gk_acaW--PQ9kRu6TPG_image.png "Output of Anomaly Detection Function")

