Source
int zbx_eval_calc_histogram_quantile(const double q, const zbx_vector_dbl_t *values, const char *err_fn,
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
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;
}
/******************************************************************************
* *