The Statistics component stores the statistics (Min, Max, Mean/Average, Median, Standard Deviation, Sum, Mode) in the component variables with the specified values.

If the value specified is an improper value for a number, that value will be excluded from the statistics. The number of values that enter the statistics without being excluded will be output to the component variables as Count.

Example.
If the test scores are flowing in as a Payload, suppose you specify “cv.Payload” for Expr and “0” for Capacity.
When the 10 values have flowed in and finished, Statistics will output an array of values as a payload.
At the same time, Statistics outputs the statistics data in the Statistics component variable.

cv.Payload [100 100 80 80 80 70 70 30 10 0]
cv.Statistics {"Average":62 "Count":10 "Max":100 "Mean":62 "Median":75 "Min":0 "Mode":[80] "StandardDeviation":34 "Sum":620}

The value expression to specify the value can be a numeric expression.
In the above example, if you specify “cv.Payload * 100”, the statistics will be taken as each value multiplied by 100.
If you want to obtain multiple statistics from a single value, or if you want to extract multiple values from the JSON Object type to obtain statistics, for example, you want to obtain statistics on multiple values at once, specify the values in an array of value expressions.
[cv.Payload, cv.Payload*100]
Assuming that the JSON Object type {"val1":123, "val2":456} flows
[cv.Payload.val1, cv.Payload.val2]
It is also possible to specify that the value expression is an array.
If you specify an array as a value expression, then the component variable Statistics will also be an array and the respective statistics will be taken.

To get statistics on sensor values in the SensorDataDB component, you can create statistics based on sensor data values by specifying the value expression property “cv.Payload.Data”.

If the data is sent in excess of the number of capacity properties, the data will be cleared up to that point once the Capacity is reached.
For example, if you set the capacity to 10 and 12 data come in, the first time you will get statistics on the data from 1-10, then these 10 data will be discarded and calculated on the 11-12th data.

Output Payload and Variable Description
cv.Payload Payload to output an array of values as an array
cv.Statistics.Average Average
cv.Statistics.Count The number of values that entered the statistics without being excluded
cv.Statistics.Max Max value
cv.Statistics.Mean Mean
cv.Statistics.Median Median
cv.Statistics.Min Minimum value
cv.Statistics.Mode Most Frequent value
cv.Statistics.StandardDeviation Standard deviation
cv.Statistics.Sum Total

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.