Wednesday, January 21, 2026
HomeLanguagesPython – Bray-Curtis distance between two 1-D arrays

Python – Bray-Curtis distance between two 1-D arrays

scipy.stats.braycurtis(array, axis=0) function calculates the Bray-Curtis distance between two 1-D arrays.

Parameters :
array: Input array or object having the elements to calculate the distance between each pair of the two collections of inputs.
axis: Axis along which to be computed. By default axis = 0

Returns : distance between each pair of the two collections of inputs.

Code #1 : 1D Array




from scipy.spatial.distance import braycurtis
  
a = [3, 1]
  
b = [2, 1]
arr1 = braycurtis(a, b) 
  
print("Value of braycurtis is :", arr1) 


Output:

Value of braycurtis is : 0.14285714285714285

Code #2 : 2D Array




from scipy.spatial.distance import braycurtis
   
arr1 = [1, 3, 27]
    
arr2 = [3, 6, 8
     
print("Value of braycurtis is :", braycurtis(arr1, arr2))  
   


Output:

Value of braycurtis is : 0.5
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7220 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS