diff options
author | Luca Deri <deri@ntop.org> | 2023-12-27 22:42:37 +0100 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2023-12-27 22:42:37 +0100 |
commit | 1366518bff88210008159cc385f092bd5cfc6252 (patch) | |
tree | 2a4db00c945c178a5636fb39d6d0e6fc0ea30727 /example | |
parent | 99d48383286fbb865ab58db5e5f768d8ed14f41e (diff) |
Implements ndpi_pearson_correlation for measuring how correlated are two series
Diffstat (limited to 'example')
-rw-r--r-- | example/ndpiReader.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index e3070a47f..91463bb02 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -5488,6 +5488,18 @@ void binaryBitmapUnitTest() { /* *********************************************** */ +void pearsonUnitTest() { + u_int32_t data_a[] = {1, 2, 3, 4, 5}; + u_int32_t data_b[] = {1000, 113, 104, 105, 106}; + u_int16_t num = sizeof(data_a) / sizeof(u_int32_t); + float pearson = ndpi_pearson_correlation(data_a, data_b, num); + + assert(pearson != 0.0); + // printf("%.8f\n", pearson); +} + +/* *********************************************** */ + void domainSearchUnitTest() { ndpi_domain_classify *sc = ndpi_domain_classify_alloc(); char *domain = "ntop.org"; @@ -5576,6 +5588,7 @@ int main(int argc, char **argv) { exit(0); #endif + pearsonUnitTest(); binaryBitmapUnitTest(); domainSearchUnitTest(); domainSearchUnitTest2(); |