Skip to main content

exponentialTimeDecayedAvg

exponentialTimeDecayedAvg

Returns the exponentially smoothed weighted moving average of values of a time series at point t in time.

Syntax

exponentialTimeDecayedAvg(x)(v, t)

Arguments

Parameters

Returned values

  • Returns an exponentially smoothed weighted moving average at index t in time. Float64.

Examples

Query:

SELECT
value,
time,
round(exp_smooth, 3),
bar(exp_smooth, 0, 5, 50) AS bar
FROM
(
SELECT
(number = 0) OR (number >= 25) AS value,
number AS time,
exponentialTimeDecayedAvg(10)(value, time) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS exp_smooth
FROM numbers(50)
);

Response:

   ┌─value─┬─time─┬─round(exp_smooth, 3)─┬─bar────────┐
1.101 │ ██████████ │
2.010.475 │ ████▊ │
3.020.301 │ ███ │
4.030.214 │ ██▏ │
5.040.162 │ █▌ │
6.050.128 │ █▎ │
7.060.104 │ █ │
8.070.086 │ ▊ │
9.080.072 │ ▋ │
0.090.061 │ ▌ │
1.0100.052 │ ▌ │
2.0110.045 │ ▍ │
3.0120.039 │ ▍ │
4.0130.034 │ ▎ │
5.0140.03 │ ▎ │
6.0150.027 │ ▎ │
7.0160.024 │ ▏ │
8.0170.021 │ ▏ │
9.0180.018 │ ▏ │
0.0190.016 │ ▏ │
1.0200.015 │ ▏ │
2.0210.013 │ ▏ │
3.0220.012 │ │
4.0230.01 │ │
5.0240.009 │ │
6.1250.111 │ █ │
7.1260.202 │ ██ │
8.1270.283 │ ██▊ │
9.1280.355 │ ███▌ │
0.1290.42 │ ████▏ │
1.1300.477 │ ████▊ │
2.1310.529 │ █████▎ │
3.1320.576 │ █████▊ │
4.1330.618 │ ██████▏ │
5.1340.655 │ ██████▌ │
6.1350.689 │ ██████▉ │
7.1360.719 │ ███████▏ │
8.1370.747 │ ███████▍ │
9.1380.771 │ ███████▋ │
0.1390.793 │ ███████▉ │
1.1400.813 │ ████████▏ │
2.1410.831 │ ████████▎ │
3.1420.848 │ ████████▍ │
4.1430.862 │ ████████▌ │
5.1440.876 │ ████████▊ │
6.1450.888 │ ████████▉ │
7.1460.898 │ ████████▉ │
8.1470.908 │ █████████ │
9.1480.917 │ █████████▏ │
0.1490.925 │ █████████▏ │
└───────┴──────┴──────────────────────┴────────────┘