canberra: Canberra and related distances

Description Usage Arguments Details Value Examples

Description

The Canberra distance and Clark's coefficient of divergence are measures that use the absolute difference over the sum for each element of the vectors.

Usage

1
2
3

Arguments

x, y

Numeric vectors

Details

For vectors x and y, the Canberra distance is defined as

d(x, y) = ∑_i \frac{|x_i - y_i|}{x_i + y_i}.

Elements where x_i + y_i = 0 are not included in the sum. Relation of canberra() to other definitions:

Clark's coefficient of divergence involves summing squares and taking a square root afterwards:

d(x, y) = √{ \frac{1}{n} ∑_i ≤ft( \frac{x_i - y_i}{x_i + y_i} \right)^2 },

where n is the number of elements where x > 0, y > 0, or both. Relation of clark_coefficient_of_divergence() to other definitions:

Value

The Canberra distance or Clark's coefficient of divergence. If every element in x and y is zero, Clark's coefficient of divergence is undefined, and we return NaN.

Examples

1
2
3
4
x <- c(15, 6, 4, 0, 3, 0)
y <- c(10, 2, 0, 1, 1, 0)
canberra(x, y)
clark_coefficient_of_divergence(x, y)

kylebittinger/abdiv documentation built on Jan. 19, 2020, 3:48 a.m.