Picture of the author

Interval Matters: How Time Granularity Shapes Time Series Calculations

Timeseries, Calculation

The interval used can have a large impact on the resulting data of a calculation, particularly when using multiplication or division.

To demonstrate this, consider the following history grid with an interval of 5minutes. The first two value columns represent two inputs; the energy usage and the production volume of an arbitrary process. The last column represents a calculation; the quotient of the energy usage and production volume (i.e. the energy used per unit produced).

timestampEnergyProductEnergy/Product
00:00961.50
00:05616.00
00:10732.33
00:15212.00
AVG: 2.96

If the same calculations were to be performed at an interval of 10minutes, the following history grid would be produced:

timestampEnergyProductEnergy/Product
00:001572.14
00:10942.25
AVG: 2.20

In both cases, the exact same data is used and the same total time is considered (20minutes). However, the resulting average of the calculations differ significantly between the two grids. Both are correct for their respective intervals. So which interval is correct for each use case must be considered carefully.

The impact of using different intervals may be counterintuitive for some (as it was for me). An easier way to consider it may be to consider the alignment of data. In the above example, it may be the case that there is a lag between the energy used to produce something and the actual production being recorded. In which case a much wider interval may make more sense.

There is another common use case where we want to do the calculation once, using data from the entire time range.

Sticking with our example above, instead of performing the calculations for each row of data, the energy and production values for the entire range are folded into single values and the required calculation is done once.

timestampEnergyProductEnergy/Product
entire range24112.18

Note that calculated value of 2.18 is different yet again from the respective average figures in the tables above.