SciPy

scipy.spatial.distance.braycurtis

scipy.spatial.distance.braycurtis(u, v)[source]

Computes the Bray-Curtis distance between two 1-D arrays.

Bray-Curtis distance is defined as

\sum{|u_i-v_i|} / \sum{|u_i+v_i|}

The Bray-Curtis distance is in the range [0, 1] if all coordinates are positive, and is undefined if the inputs are of length zero.

Parameters :

u : (N,) array_like

Input array.

v : (N,) array_like

Input array.

Returns :

braycurtis : double

The Bray-Curtis distance between 1-D arrays u and v.