Overview:
-
The Bray-Curtis distance is more of a measure of dissimilarity than a distance.
-
Given two samples, the Bray-Curtis distance indicates how dissimilar two samples are.
-
The Bray-Curtis distance was first introduced in ecological studies and is predominantly used in ecology to study about the population of species found in different locations.
-
The Bray-Curtis distance is a normalized value that varies between 0 and 1. A Bray-Curtis dissimilarity of 1 means the data compared are completely dissimilar. A value of 0 means both the data are exactly similar.
-
The formula for the Bray-Curtis dissimilarity matrix is given by
Dissimilarity index = 1-(2w/a+b) -
The species with the lowest count that are common to both the samples are added together and multiplied by two which is divided by the total number of species in both the samples.
-
The obtained value is inverted by subtracting from 1 which gives the Bray-Curtis dissimilarity mesure.
-
w – Total number of species which are the lowest in Sample 1 and Sample 2, for the ones that are commonly present in both the samples.
a – Total number of species from Sample 1
b – Total number of species from Sample 2
-
The SciPy function from braycurtis() the scipy.spatial.distance module computes and returns the Bray-Curtis distance for the data passed as two one-dimensional arrays.
Example:
# Example Python program that finds the Bray-curtis distance # Number of species(species pluralis) in each group of # Find how dissimilar the two mountain ranges are in |
Output:
Bray-curtis distance: 0.3371794871794872 |