From 57b86cfe9efac495846ccee1306a366c786f40af Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 22 Dec 2021 21:30:14 -0500 Subject: [PATCH 1/2] docs: update function docs on deriv Signed-off-by: mtfoley --- docs/querying/functions.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/querying/functions.md b/docs/querying/functions.md index 33740ac4a..f648faac4 100644 --- a/docs/querying/functions.md +++ b/docs/querying/functions.md @@ -130,6 +130,11 @@ delta(cpu_temp_celsius{host="zeus"}[2h]) `deriv(v range-vector)` calculates the per-second derivative of the time series in a range vector `v`, using [simple linear regression](https://en.wikipedia.org/wiki/Simple_linear_regression). +The range vector must have at least two samples in order to perform the calculation. The linear +regression is used to calculate a slope and offset for a trend line, and the slope value is used +for the derivative calculation. In order to reduce calculation errors, the timestamp of the first +sample in the range vector is set as `x=0` within the linear regression algorithm. When `+Inf` or +`-Inf` are found in the range vector, the slope and offset value calculated will be `NaN`. `deriv` should only be used with gauges. @@ -329,6 +334,13 @@ January etc. `predict_linear(v range-vector, t scalar)` predicts the value of time series `t` seconds from now, based on the range vector `v`, using [simple linear regression](https://en.wikipedia.org/wiki/Simple_linear_regression). +The range vector must have at least two samples in order to perform the +calculation. The linear regression is used to calculate a slope and offset +for a trend line, and the slope and offset are used to calculate the predict +the value of the time series. In order to reduce calculation errors, the +timestamp of the first sample in the range vector is set as `x=0` within the +linear regression algorithm. When `+Inf` or `-Inf` are found in the range vector, +the slope and offset value calculated will be `NaN`. `predict_linear` should only be used with gauges. @@ -456,4 +468,4 @@ The following are useful for converting between degrees and radians: - `deg(v instant-vector)`: converts radians to degrees for all elements in `v`. - `pi()`: returns pi. -- `rad(v instant-vector)`: converts degrees to radians for all elements in `v`. \ No newline at end of file +- `rad(v instant-vector)`: converts degrees to radians for all elements in `v`. From b6630876d336b823dcdc7a4de160b6446f30401f Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 19 Feb 2022 08:41:38 -0500 Subject: [PATCH 2/2] remove impl details from docs Signed-off-by: mtfoley --- docs/querying/functions.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/docs/querying/functions.md b/docs/querying/functions.md index 3b557a0e0..5da40a042 100644 --- a/docs/querying/functions.md +++ b/docs/querying/functions.md @@ -130,10 +130,7 @@ delta(cpu_temp_celsius{host="zeus"}[2h]) `deriv(v range-vector)` calculates the per-second derivative of the time series in a range vector `v`, using [simple linear regression](https://en.wikipedia.org/wiki/Simple_linear_regression). -The range vector must have at least two samples in order to perform the calculation. The linear -regression is used to calculate a slope and offset for a trend line, and the slope value is used -for the derivative calculation. In order to reduce calculation errors, the timestamp of the first -sample in the range vector is set as `x=0` within the linear regression algorithm. When `+Inf` or +The range vector must have at least two samples in order to perform the calculation. When `+Inf` or `-Inf` are found in the range vector, the slope and offset value calculated will be `NaN`. `deriv` should only be used with gauges. @@ -335,11 +332,7 @@ January etc. `t` seconds from now, based on the range vector `v`, using [simple linear regression](https://en.wikipedia.org/wiki/Simple_linear_regression). The range vector must have at least two samples in order to perform the -calculation. The linear regression is used to calculate a slope and offset -for a trend line, and the slope and offset are used to calculate the predict -the value of the time series. In order to reduce calculation errors, the -timestamp of the first sample in the range vector is set as `x=0` within the -linear regression algorithm. When `+Inf` or `-Inf` are found in the range vector, +calculation. When `+Inf` or `-Inf` are found in the range vector, the slope and offset value calculated will be `NaN`. `predict_linear` should only be used with gauges.