scipy.spatial.distance.dice

scipy.spatial.distance.dice(u, v, w=None)[源代码]

计算两个一维布尔数组之间的骰子相异度。

骰子的不同之处在于 uv ,是

\[\frac{c_{tf}+c_{ft}} {2c_{tt}+c_{ft}+c_{tf}}\]

哪里 \(c_{{ij}}\) 是出现的次数 \(\mathtt{{u[k]}} = i\)\(\mathtt{{v[k]}} = j\)\(k < n\)

参数
u(n,)类似数组,布尔

输入一维数组。

v(n,)类似数组,布尔

输入一维数组。

w(n,)array_like,可选

中每个值的权重 uv 。默认值为None,即为每个值赋予1.0的权重

退货
dice双倍

一维阵列之间的骰子差异 uv

示例

>>> from scipy.spatial import distance
>>> distance.dice([1, 0, 0], [0, 1, 0])
1.0
>>> distance.dice([1, 0, 0], [1, 1, 0])
0.3333333333333333
>>> distance.dice([1, 0, 0], [2, 0, 0])
-0.3333333333333333