Skip to content

Canberra dist and double zeros

1 message · Brian Ripley

#
[Moved to R-devel, as more appropriate.]
On Mon, 5 Mar 2001, Jari Oksanen wrote:

            
I am sure we should do something, but is this exactly right?  From dist()
in the R-devel version (1.3.x, eventually) I have enabled the handling of
missing values.  With this solution, identically zero elements contribute
zero to the distance, and are not regarded as missing.  Canberra is
similar to binary, where x_i = y_i = 0 is treated as equivalent to
missing.  The issue is if count should be incremented if
sum == 0.0 or not.

A related issue is the test (sum > 0.0).  I guess there are potential
problems with optimization on machines that use extended-precision
arithmetic, where sum might be non-zero in a register but zero if stored.
Not sure if that can actually happen, but a tolerance (e.g. machar's
xmax) is usually safer.