diff options
author | Luca Deri <deri@ntop.org> | 2021-06-18 22:56:56 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2021-06-18 22:56:56 +0200 |
commit | 613e21002adfe5d536c632757cee2b4e6bda847b (patch) | |
tree | 46ee3d19520d2db78ba88ea0103de78c4716568e | |
parent | 0afc8ace3d2da3ff67c13cf3e95f722bdc981170 (diff) |
Upgraded exponential smoothing to 64 bit values
-rw-r--r-- | src/include/ndpi_api.h.in | 6 | ||||
-rw-r--r-- | src/include/ndpi_typedefs.h | 2 | ||||
-rw-r--r-- | src/lib/ndpi_analyze.c | 12 |
3 files changed, 10 insertions, 10 deletions
diff --git a/src/include/ndpi_api.h.in b/src/include/ndpi_api.h.in index d1e50778f..cfee592c7 100644 --- a/src/include/ndpi_api.h.in +++ b/src/include/ndpi_api.h.in @@ -1489,17 +1489,17 @@ extern "C" { int ndpi_hw_init(struct ndpi_hw_struct *hw, u_int16_t num_periods, u_int8_t additive_seeasonal, double alpha, double beta, double gamma, float significance); void ndpi_hw_free(struct ndpi_hw_struct *hw); - int ndpi_hw_add_value(struct ndpi_hw_struct *hw, const u_int32_t value, double *forecast, double *confidence_band); + int ndpi_hw_add_value(struct ndpi_hw_struct *hw, const u_int64_t value, double *forecast, double *confidence_band); /* ******************************* */ int ndpi_ses_init(struct ndpi_ses_struct *ses, double alpha, float significance); - int ndpi_ses_add_value(struct ndpi_ses_struct *ses, const u_int32_t _value, double *forecast, double *confidence_band); + int ndpi_ses_add_value(struct ndpi_ses_struct *ses, const u_int64_t _value, double *forecast, double *confidence_band); /* ******************************* */ int ndpi_des_init(struct ndpi_des_struct *des, double alpha, double beta, float significance); - int ndpi_des_add_value(struct ndpi_des_struct *des, const u_int32_t _value, double *forecast, double *confidence_band); + int ndpi_des_add_value(struct ndpi_des_struct *des, const u_int64_t _value, double *forecast, double *confidence_band); /* ******************************* */ diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index 4fee4e4d4..173f3baff 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -1720,7 +1720,7 @@ struct ndpi_hw_struct { double u, v, sum_square_error; /* These two values need to store the signal history */ - u_int32_t *y; + u_int64_t *y; double *s; }; diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c index 349b51cea..9b642ddd3 100644 --- a/src/lib/ndpi_analyze.c +++ b/src/lib/ndpi_analyze.c @@ -1,7 +1,7 @@ /* * ndpi_analyze.c * - * Copyright (C) 2019 - ntop.org + * Copyright (C) 2019-21 - ntop.org * * This file is part of nDPI, an open source deep packet inspection * library. @@ -932,7 +932,7 @@ static double ndpi_normal_cdf_inverse(double p) { } } -double ndpi_avg_inline(u_int32_t *v, u_int num) { +double ndpi_avg_inline(u_int64_t *v, u_int num) { double avg = 0; u_int i; @@ -981,7 +981,7 @@ int ndpi_hw_init(struct ndpi_hw_struct *hw, if((significance < 0) || (significance > 1)) significance = 0.05; hw->params.ro = ndpi_normal_cdf_inverse(1 - (significance / 2.)); - if((hw->y = (u_int32_t*)ndpi_calloc(hw->params.num_season_periods, sizeof(u_int32_t))) == NULL) + if((hw->y = (u_int64_t*)ndpi_calloc(hw->params.num_season_periods, sizeof(u_int64_t))) == NULL) return(-1); if((hw->s = (double*)ndpi_calloc(hw->params.num_season_periods, sizeof(double))) == NULL) { @@ -1017,7 +1017,7 @@ void ndpi_hw_free(struct ndpi_hw_struct *hw) { 0 Too early: we're still in the learning phase. Output values are zero. 1 Normal processing: forecast and confidence_band are meaningful */ -int ndpi_hw_add_value(struct ndpi_hw_struct *hw, const u_int32_t _value, double *forecast, double *confidence_band) { +int ndpi_hw_add_value(struct ndpi_hw_struct *hw, const u_int64_t _value, double *forecast, double *confidence_band) { if(hw->num_values < hw->params.num_season_periods) { hw->y[hw->num_values++] = _value; @@ -1193,7 +1193,7 @@ int ndpi_ses_init(struct ndpi_ses_struct *ses, double alpha, float significance) 0 Too early: we're still in the learning phase. Output values are zero. 1 Normal processing: forecast and confidence_band are meaningful */ -int ndpi_ses_add_value(struct ndpi_ses_struct *ses, const u_int32_t _value, double *forecast, double *confidence_band) { +int ndpi_ses_add_value(struct ndpi_ses_struct *ses, const u_int64_t _value, double *forecast, double *confidence_band) { double value = (double)_value, error, sq_error; int rc; @@ -1265,7 +1265,7 @@ int ndpi_des_init(struct ndpi_des_struct *des, double alpha, double beta, float 0 Too early: we're still in the learning phase. Output values are zero. 1 Normal processing: forecast and confidence_band are meaningful */ -int ndpi_des_add_value(struct ndpi_des_struct *des, const u_int32_t _value, double *forecast, double *confidence_band) { +int ndpi_des_add_value(struct ndpi_des_struct *des, const u_int64_t _value, double *forecast, double *confidence_band) { double value = (double)_value, error, sq_error; int rc; |