Source
int zbx_eval_calc_histogram_quantile(const double q, const zbx_vector_dbl_t *values, const char *err_fn,
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
typedef struct
{
double upper;
double count;
}
zbx_histogram_t;
ZBX_VECTOR_DECL(histogram, zbx_histogram_t)
ZBX_VECTOR_IMPL(histogram, zbx_histogram_t)
static int zbx_is_normal_double(double dbl)
{
if (FP_ZERO != fpclassify(dbl) && FP_NORMAL != fpclassify(dbl))
return FAIL;
return SUCCEED;
}
/******************************************************************************
* *
* Purpose: calculates arithmetic mean (i.e. average) *
* *
* Parameters: v - [IN] non-empty vector with input data *
* *
* Return value: arithmetic mean value *
* *
******************************************************************************/
static double calc_arithmetic_mean(const zbx_vector_dbl_t *v)
{
double sum = 0;
int i;
for (i = 0; i < v->values_num; i++)
sum += v->values[i];
return sum / v->values_num;
}
/******************************************************************************
* *
* Purpose: evaluates function 'kurtosis' *
* *
* Parameters: values - [IN] non-empty vector with input data *
* result - [OUT] calculated value *
* error - [OUT] dynamically allocated error message *