fix query sum (#4482)
* fix sum * added query rsd as an alias of cv
Costa Tsaousis committed
Oct 24, 2018 at 23:55 UTC
6c5fc794f077c9affe6892d24d8e1d5a78956fc6
3 files changed
+16
-7
web/api/queries/query.c
+11
-1
@@ -145,7 +145,17 @@ static struct {
145
.hash = 0,
146
.value = RRDR_GROUPING_CV,
147
.init = NULL,
148
- .create= grouping_create_stddev, // not an error, stddev calculates this too
148
+ .create= grouping_create_stddev, // not an error, stddev calculates this too
149
+ .reset = grouping_reset_stddev, // not an error, stddev calculates this too
150
+ .free = grouping_free_stddev, // not an error, stddev calculates this too
151
+ .add = grouping_add_stddev, // not an error, stddev calculates this too
152
+ .flush = grouping_flush_coefficient_of_variation
153
+ },
154
+ {.name = "rsd", // alias of 'cv'
155
+ .hash = 0,
156
+ .value = RRDR_GROUPING_CV,
157
+ .init = NULL,
158
+ .create= grouping_create_stddev, // not an error, stddev calculates this too
159
.reset = grouping_reset_stddev, // not an error, stddev calculates this too
160
.free = grouping_free_stddev, // not an error, stddev calculates this too
161
.add = grouping_add_stddev, // not an error, stddev calculates this too
web/api/queries/stddev/README.md
+3
-1
@@ -41,7 +41,9 @@ Check [https://en.wikipedia.org/wiki/Standard_deviation](https://en.wikipedia.or
41
42
# Coefficient of variation (`cv`)
43
44
-The coefficient of variation (`cv``), also known as relative standard deviation (RSD),
44
+> This query is also available as `rsd`.
45
+
46
+The coefficient of variation (`cv`), also known as relative standard deviation (`rsd`),
47
is a standardized measure of dispersion of a probability distribution or frequency distribution.
48
49
It is defined as the ratio of the **standard deviation** to the **mean**.
web/api/queries/sum/sum.c
+2
-5
@@ -31,11 +31,8 @@ void grouping_free_sum(RRDR *r) {
31
void grouping_add_sum(RRDR *r, calculated_number value) {
32
if(!isnan(value)) {
33
struct grouping_sum *g = (struct grouping_sum *)r->internal.grouping_data;
34
-
35
- if(!g->count || calculated_number_fabs(value) > calculated_number_fabs(g->sum)) {
36
- g->sum += value;
37
- g->count++;
38
- }
34
+ g->sum += value;
35
+ g->count++;
36
}
37
}
38