| bray_curtis {abdiv} | R Documentation |
Bray-Curtis distance
Description
The Bray-Curtis distance is the Manhattan distance divided by the sum of both vectors.
Usage
bray_curtis(x, y)
Arguments
x, y |
Numeric vectors |
Details
For two vectors x and y, the Bray-Curtis distance is defined
as
d(x, y) = \frac{\sum_i |x_i - y_i|}{\sum_i x_i + y_i}.
The Bray-Curtis distance is connected to many other distance measures in this package; we try to list some of the more important connections here. Relation to other definitions:
Equivalent to
vegdist()withmethod = "bray".Equivalent to the
braycurtis()function inscipy.spatial.distancefor positive vectors. They take the absolute value ofx_i + y_iin the denominator.Equivalent to the
braycurtisandodumcalculators in Mothur.Equivalent to
D_{14} = 1 - S_{17}in Legendre & Legendre.The Bray-Curtis distance on proportions is equal to half the Manhattan distance.
The Bray-Curtis distance on presence/absence vectors is equal to the Sorenson index of dissimilarity.
Value
The Bray-Curtis distance between x and y. The
Bray-Curtis distance is undefined if the sum of all elements in x
and y is zero, in which case we return NaN.
Examples
x <- c(15, 6, 4, 0, 3, 0)
y <- c(10, 2, 0, 1, 1, 0)
bray_curtis(x, y)
# For proportions, equal to half the Manhattan distance
bray_curtis(x / sum(x), y / sum(y))
manhattan(x / sum(x), y / sum(y)) / 2