updated exponentialMovingAverage to address PR feedback
parent
31115c4d36
commit
94bf2c5cae
content/v2.0/reference/flux/functions/built-in/transformations/aggregates
|
@ -2,7 +2,7 @@
|
||||||
title: exponentialMovingAverage() function
|
title: exponentialMovingAverage() function
|
||||||
description: >
|
description: >
|
||||||
The `exponentialMovingAverage()` function calculates the exponential moving average
|
The `exponentialMovingAverage()` function calculates the exponential moving average
|
||||||
of values grouped into `n` number of points giving more weight to recent data.
|
of values grouped into `n` number of points, giving more weight to recent data.
|
||||||
menu:
|
menu:
|
||||||
v2_0_ref:
|
v2_0_ref:
|
||||||
name: exponentialMovingAverage
|
name: exponentialMovingAverage
|
||||||
|
@ -15,7 +15,7 @@ related:
|
||||||
---
|
---
|
||||||
|
|
||||||
The `exponentialMovingAverage()` function calculates the exponential moving average
|
The `exponentialMovingAverage()` function calculates the exponential moving average
|
||||||
of values grouped into `n` number of points giving more weight to recent data.
|
of values grouped into `n` number of points, giving more weight to recent data.
|
||||||
|
|
||||||
_**Function type:** Aggregate_
|
_**Function type:** Aggregate_
|
||||||
|
|
||||||
|
@ -28,11 +28,11 @@ exponentialMovingAverage(
|
||||||
|
|
||||||
##### Exponential moving average rules:
|
##### Exponential moving average rules:
|
||||||
- The first value of an exponential moving average over `n` values is the
|
- The first value of an exponential moving average over `n` values is the
|
||||||
algebraic mean of the first `n` values.
|
algebraic mean of `n` values.
|
||||||
- Subsequent values are calculated as `y(t) = x(t) * k + y(t-1) * (1 - k)`, where:
|
- Subsequent values are calculated as `y(t) = x(t) * k + y(t-1) * (1 - k)`, where:
|
||||||
- `k = 2 / (1 + n)`.
|
|
||||||
- `y(t)` is the exponential moving average at time `t`.
|
- `y(t)` is the exponential moving average at time `t`.
|
||||||
- `x(t)` is the value at time `t`.
|
- `x(t)` is the value at time `t`.
|
||||||
|
- `k = 2 / (1 + n)`.
|
||||||
- The average over a period populated by only `null` values is `null`.
|
- The average over a period populated by only `null` values is `null`.
|
||||||
- Exponential moving averages skip `null` values.
|
- Exponential moving averages skip `null` values.
|
||||||
|
|
||||||
|
@ -57,13 +57,6 @@ from(bucket: "example-bucket"):
|
||||||
|> exponentialMovingAverage(n: 5)
|
|> exponentialMovingAverage(n: 5)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Calculate a ten point exponential moving average
|
|
||||||
```js
|
|
||||||
from(bucket: "example-bucket"):
|
|
||||||
|> range(start: -12h)
|
|
||||||
|> exponentialMovingAverage(n: 10)
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Table transformation with a two point exponential moving average
|
#### Table transformation with a two point exponential moving average
|
||||||
|
|
||||||
###### Input table:
|
###### Input table:
|
||||||
|
|
Loading…
Reference in New Issue