Compute time-based exponentially weighted moving average
Description
Given observations x0, x1, …, xn − 1 at times t0, t1, …, tn − 1, the EWMA is calculated as
*y*0 = *x*0
$\alpha_i = 1 - \exp \left\\ \frac{ -\ln(2)(t_i-t\_{i-1}) } { \tau } \right\\$
*y**i* = *α**i**x**i* + (1 − *α**i*)*y**i* − 1; *i* \> 0
where *τ* is the half_life
.
## Usage
expr__ewm_mean_by(by, ..., half_life)
## Arguments
by
|
Times to calculate average by. Should be DateTime, Date, UInt64, UInt32, Int64, or Int32 data type. |
…
|
These dots are for future extensions and must be empty. |
half_life
|
Unit over which observation decays to half its value. Can be created
either from a timedelta, or by using the following string language:
“3d12h4m25s” \# 3 days, 12 hours, 4
minutes, and 25 seconds
By "calendar day", we mean the corresponding time on the next day (which
may not be 24 hours, due to daylight savings). Similarly for "calendar
week", "calendar month", "calendar quarter", and "calendar year".
|