Have you ever tried to calculate the average of all the data points in a time period and wondered why you arrived at a different value from Flow?
The reason for this is because Flow always uses a time weighted average when determining an average.
Let's use the sample data that we used when discussing the Basic Aggregation Methods.
|Point||Timestamp||Raw Value||Duration (seconds)||Weighted Value|
You'll notice that we've added two columns to our sample data: Duration and Weighted Value.
For each data point in a time period, Flow will determine how long that data point was valid for - this is shown in the Duration column above.
The first data point's (which is the "boundary" value) duration is calculated from the start of the time period that is being processed (in this case from 06:00:00) until the next data point's timestamp.
The last data point's (in this case Point 13 and not Point 14, which is outside of the time period being processed) duration is calculated from it's timestamp until the end of the time period (in this case until 07:00:00)
For each data point (including the starting / boundary value, but excluding the last point that is outside of the time period) Flow calculates a weighted value as follows:
Weighted Value = Value * (Duration / Total Time Period Duration)
In the above example, the Total Time Period Duration = 3600s, because Flow is processing an hourly time period.
While the example above demonstrates the concept using seconds, Flow actually does all time-related calculations in milliseconds.
Thereafter, Flow adds all the time-weighted values together to get a time-weighted average.
With the above data points, Average = 2.213722222
When a time weighted average is applied to a rate, the result is effectively a mathematical integration of the rate, which is the total for that time period. For example, if one performs a time weighted average on a Flow Rate (liters/hr), the result is the total quantity of liters measured in that hour.