Skip to main content

Background

This use case is centered on finding the median value of a collection of tags. In TrendMiner, it is simple to calculate the mean or average value of a set of tags. This can be done in our formula tag builder. In some cases, however, the median value proves to be more useful of a central statistic than the mean. For example, consider a furnace where there are multiple thermocouples measuring the same point temperature. If one of these thermocouples were to malfunction and read a very high or very low value, the mean value will be skewed high or low, respectively. When outliers exist in the data, the median value proves to be a useful central statistic.

 

Challenge

There is no built-in function in formula tag builder for calculating the median value of a collection of tags. A simple, manual formula can be created to find the median for a collection of two or three tags; however, the manual formula grows exponentially when additional tags are added. Writing a formula to calculate the median for 8 tags, for example, becomes an extremely tedious task.

 

Solution

A much simpler solution to calculate the median value is to leverage custom calculation within tag builder. In custom calculation, we can use Python code and the TrendMiner SDK to simplify the median value tag calculation and creation. See below for an example of calculating the median value of three tags.

Once the code script is written, the user can preview the results by selecting the Run button.

If the preview of the tag looks good, the user can save the tag and begin using it just like any other tag in TrendMiner.

In the image above, the bottom tag is the median tag created in custom calculation. We can verify that the median tag is correctly calculating the median value by adding data scooters to the focus chart.

 

Value

As mentioned previously, the median value can come in handy when outliers are present in the data. Outliers skew average values whereas the median can still provide an accurate central statistic. Using custom calculation to calculate the median can save TrendMiner users a lot of time over the traditional method of creating a similar tag in formula tag builder.

 

I hope this post helps - please comment below if you found this helpful and what kind of application you would like to use it for.

Be the first to reply!

Reply