Source
static void step(const zbx_vector_history_record_t *y, int n, int np, int ns, int nt, int nl, int isdeg, int itdeg,
/*
** 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.
**/
ZBX_PTR_VECTOR_DECL(VV, zbx_vector_history_record_t *)
ZBX_PTR_VECTOR_IMPL(VV, zbx_vector_history_record_t *)
/*******************************************************************************
* *
* Purpose: finds how many values in stl remainder are outliers *
* *
* Parameters: remainder - [IN] stl remainder values vector *
* deviations_count - [IN] how much a value can be away from the *
* (mad, stdevsamp or stdevpop) to get *
* counted as an outlier *
* devalg - [IN] function (mad, stdevsamp or stdevpop) *
* to evaluate a single deviation unit *
* detect_period_start - [IN] evaluate number of deviations in *
* remainder starting from this time *
* detect_period - [IN] evaluate number of deviations in *
* remainder until this time *
* result - [OUT] result - double, a percentage how *
* many outliers are in remainder *
* error - [OUT] the error message *
* *
* Return value: SUCCEED - evaluated successfully, 'result' contains new value *
* FAIL - evaluation failed, 'result' contains old value *
* *
*******************************************************************************/
int zbx_get_percentage_of_deviations_in_stl_remainder(const zbx_vector_history_record_t *remainder,
double deviations_count, const char* devalg, int detect_period_start, int detect_period_end,
double *result, char **error)
{
int i, total_values_count = 0, deviations_detected_count = 0, ret = FAIL;
double remainder_deviation, deviation_limit;
zbx_statistical_func_t stat_func;
zbx_vector_dbl_t remainder_values_dbl;
zbx_vector_dbl_create(&remainder_values_dbl);
if (0 == remainder->values_num)
{