📜  Python – 两个一维数组之间的 Bray-Curtis 距离

📅  最后修改于: 2022-05-13 01:54:57.004000             🧑  作者: Mango

Python – 两个一维数组之间的 Bray-Curtis 距离

scipy.stats.braycurtis(array, axis=0)函数计算两个一维数组之间的 Bray-Curtis 距离。

代码#1:一维数组

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

输出:

Value of braycurtis is : 0.14285714285714285

代码 #2:二维数组

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

输出:

Value of braycurtis is : 0.5