updated exponentialMovingAverage to address PR feedback

pull/328/head
Scott Anderson 2019-07-15 08:57:32 -06:00
parent 31115c4d36
commit 94bf2c5cae
1 changed files with 4 additions and 11 deletions

View File

@ -2,7 +2,7 @@
title: exponentialMovingAverage() function
description: >
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:
v2_0_ref:
name: exponentialMovingAverage
@ -15,7 +15,7 @@ related:
---
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_
@ -28,11 +28,11 @@ exponentialMovingAverage(
##### Exponential moving average rules:
- 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:
- `k = 2 / (1 + n)`.
- `y(t)` is the exponential moving average 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`.
- Exponential moving averages skip `null` values.
@ -57,13 +57,6 @@ from(bucket: "example-bucket"):
|> 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
###### Input table: