From 732579b72b1e58de58502520fc678e87ea757677 Mon Sep 17 00:00:00 2001 From: Luca Deri Date: Mon, 8 Feb 2021 19:10:25 +0100 Subject: Added timeseries forecasting support implementing Holt-Winters with confidence interval New API calls added - ndpi_hw_init() - ndpi_hw_add_value() - ndpi_hw_free() --- example/ndpiReader.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'example/ndpiReader.c') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 5ece4e414..758d59ec9 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -3733,6 +3733,40 @@ void hashUnitTest() { /* *********************************************** */ +void hwUnitTest() { + struct ndpi_hw_struct hw; + double v[] = { 10, 14, 8, 25, 16, 22, 14, 35, 15, 27, 218, 40, 28, 40, 25, 65 }; + u_int i, j, num = sizeof(v) / sizeof(double); + u_int num_learning_points = 2; + u_int8_t trace = 0; + + for(j=0; j<2; j++) { + assert(ndpi_hw_init(&hw, num_learning_points, j /* 0=multiplicative, 1=additive */, 0.9, 0.9, 0.1, 0.05) == 0); + + if(trace) + printf("\nHolt-Winters %s method\n", (j == 0) ? "multiplicative" : "additive"); + + for(i=0; i= lower) && (v[i] <= upper))) ? "OK" : "ANOMALY", + confidence_band); + } + + ndpi_hw_free(&hw); + } + + exit(0); +} + +/* *********************************************** */ + /** @brief MAIN FUNCTION **/ @@ -3753,8 +3787,9 @@ int orginal_main(int argc, char **argv) { if(ndpi_info_mod == NULL) return -1; - /* Internal checks */ + /* Internal checks */ // binUnitTest(); + hwUnitTest(); rsiUnitTest(); hashUnitTest(); dgaUnitTest(); -- cgit v1.2.3