[Rd] Canberra distance

Christophe Genolini cgenolin at u-paris10.fr
Sat Feb 6 16:39:31 CET 2010


Hi the list,

According to what I know, the Canberra distance between X et Y is : sum[ 
(|x_i - y_i|) / (|x_i|+|y_i|) ] (with | | denoting the function 
'absolute value')
In the source code of the canberra distance in the file distance.c, we 
find :

    sum = fabs(x[i1] + x[i2]);
    diff = fabs(x[i1] - x[i2]);
    dev = diff/sum;

which correspond to the formula : sum[ (|x_i - y_i|) / (|x_i+y_i|) ]
(note that this does not define a distance... This is correct when x_i 
and y_i are positive, but not when a value is negative.)

Is it on purpose or is it a bug?

Christophe



More information about the R-devel mailing list