-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Exponentially smoothed moving average as aggregate function. #27511
Copy link
Copy link
Closed
Labels
Description
The function will take two arguments: value and time and also parameter - half-decay period.
Example: exponentialMovingAverage(300)(temperature, timestamp)
- exponentially smoothed moving average of the temperature for the past five minutes at the latest point of time.
The state of the aggregate function is current averaged value and the latest time: (v, t).
Whenever new value or new state is appeared, the state is updated as:
t_new = max(t_old, t)
v_new = v_old * (1 / exp2((t_new - t_old) / half_decay)) + v * (1 - 1 / exp2((t_new - t_old) / half_decay))
(a sort of - did I write the formula correctly?)
(does this way of calculation depend on the order of updates?)
Reactions are currently unavailable