diff options
author | Costa Tsaousis <costa@tsaousis.gr> | 2018-10-24 23:55:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-24 23:55:22 +0300 |
commit | 6c5fc794f077c9affe6892d24d8e1d5a78956fc6 (patch) | |
tree | 283a116b8844e71f55e28c55c059e4a3fc48f433 /web/api/queries | |
parent | c9234ccc8cea6023c190370ea7e7e95fb5433dab (diff) |
fix query sum (#4482)
* fix sum
* added query rsd as an alias of cv
Diffstat (limited to 'web/api/queries')
-rw-r--r-- | web/api/queries/query.c | 12 | ||||
-rw-r--r-- | web/api/queries/stddev/README.md | 4 | ||||
-rw-r--r-- | web/api/queries/sum/sum.c | 7 |
3 files changed, 16 insertions, 7 deletions
diff --git a/web/api/queries/query.c b/web/api/queries/query.c index 070b4be9ef..764375932a 100644 --- a/web/api/queries/query.c +++ b/web/api/queries/query.c @@ -145,7 +145,17 @@ static struct { .hash = 0, .value = RRDR_GROUPING_CV, .init = NULL, - .create= grouping_create_stddev, // not an error, stddev calculates this too + .create= grouping_create_stddev, // not an error, stddev calculates this too + .reset = grouping_reset_stddev, // not an error, stddev calculates this too + .free = grouping_free_stddev, // not an error, stddev calculates this too + .add = grouping_add_stddev, // not an error, stddev calculates this too + .flush = grouping_flush_coefficient_of_variation + }, + {.name = "rsd", // alias of 'cv' + .hash = 0, + .value = RRDR_GROUPING_CV, + .init = NULL, + .create= grouping_create_stddev, // not an error, stddev calculates this too .reset = grouping_reset_stddev, // not an error, stddev calculates this too .free = grouping_free_stddev, // not an error, stddev calculates this too .add = grouping_add_stddev, // not an error, stddev calculates this too diff --git a/web/api/queries/stddev/README.md b/web/api/queries/stddev/README.md index a404b49025..3436ff834f 100644 --- a/web/api/queries/stddev/README.md +++ b/web/api/queries/stddev/README.md @@ -41,7 +41,9 @@ Check [https://en.wikipedia.org/wiki/Standard_deviation](https://en.wikipedia.or # Coefficient of variation (`cv`) -The coefficient of variation (`cv``), also known as relative standard deviation (RSD), +> This query is also available as `rsd`. + +The coefficient of variation (`cv`), also known as relative standard deviation (`rsd`), is a standardized measure of dispersion of a probability distribution or frequency distribution. It is defined as the ratio of the **standard deviation** to the **mean**. diff --git a/web/api/queries/sum/sum.c b/web/api/queries/sum/sum.c index ed81156cf3..0da9937a3a 100644 --- a/web/api/queries/sum/sum.c +++ b/web/api/queries/sum/sum.c @@ -31,11 +31,8 @@ void grouping_free_sum(RRDR *r) { void grouping_add_sum(RRDR *r, calculated_number value) { if(!isnan(value)) { struct grouping_sum *g = (struct grouping_sum *)r->internal.grouping_data; - - if(!g->count || calculated_number_fabs(value) > calculated_number_fabs(g->sum)) { - g->sum += value; - g->count++; - } + g->sum += value; + g->count++; } } |