Implements ndpi_pearson_correlation for measuring how correlated are two series

This commit is contained in:
Luca Deri
2023-12-27 22:42:37 +01:00
parent 99d4838328
commit 1366518bff
4 changed files with 108 additions and 15 deletions
+13
View File
@@ -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();