time_weight()
function, which weights each value using last observation carried forward (LOCF), or linear interpolation.
The aggregate is not parallelizable, but it is supported with continuous aggregation.
Prerequisites
To follow the steps on this page:- Create a target with Real-time analytics enabled. You need your connection details. This procedure also works for .
Calculate time-weighted averages
This example uses afreezer_temps table that simulates irregularly sampled temperature data from
freezers. The sampling rate increases when temperatures go out of range, demonstrating the value
of time-weighted averages.
-
Create the
freezer_tempshypertable -
Insert sample data with irregular sampling
This simulates sensors that sample every 5 minutes
when temperatures are in range (0-10°F), and more frequently when out of range:
-
Find the average and the time-weighted average of the data
-
Check for irregular data
To determine if the freezer has been out of temperature range for more than 15 minutes at a
time, use a time-weighted average in a window function: