scipy.spatial.distance.braycurtis#
- scipy.spatial.distance.braycurtis(u, v, w=None)[source]#
Compute 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.
- w(N,) array_like, optional
The weights for each value in u and v. Default is None, which gives each value a weight of 1.0
- Returns
- braycurtisdouble
The Bray-Curtis distance between 1-D arrays u and v.
Examples
>>> from scipy.spatial import distance >>> distance.braycurtis([1, 0, 0], [0, 1, 0]) 1.0 >>> distance.braycurtis([1, 1, 0], [0, 1, 0]) 0.33333333333333331