From 9160157ca1f6d93c28b2a086eb74cd39241e16a5 Mon Sep 17 00:00:00 2001 From: Minh Long Nguyen Date: Thu, 24 Apr 2025 23:55:16 +1000 Subject: [PATCH] Update distance.c The denominator in the formula for computing the canberra distance seems to be wrong. It should be sum = fabs(*x) + fabs(*y); instead of sum = fabs(*x + *y); --- src/distance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/distance.c b/src/distance.c index 1afdd03..85f0598 100755 --- a/src/distance.c +++ b/src/distance.c @@ -121,7 +121,7 @@ static double canberra(double *x, double *y, int nx, int ny, int nc) dist = 0; for (j = 0 ;j < nc; j++) { if (both_non_NA(*x, *y)) { - sum = fabs(*x + *y); + sum = fabs(*x) + fabs(*y); // wrong denominator before diff = fabs(*x - *y); if (sum > DBL_MIN || diff > DBL_MIN) { dev = diff/sum;