Skip to content

Exponentially smoothed moving average as aggregate function. #27511

@alexey-milovidov

Description

@alexey-milovidov

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?)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions