bulk_sokal_sneath_2_binary_distance#

skfp.distances.bulk_sokal_sneath_2_binary_distance(X: ndarray, Y: ndarray | None = None) ndarray#

Bulk Sokal-Sneath distance 2 for vectors of binary values.

Computes the pairwise Sokal-Sneath distance 2 between binary matrices. If one array is passed, distances are computed between its rows. For two arrays, distances are between their respective rows, with i-th row and j-th column in output corresponding to i-th row from first array and j-th row from second array.

See also sokal_sneath_2_binary_distance().

Parameters:
  • X (ndarray) – First binary input array, of shape \(m \times m\)

  • Y (ndarray, default=None) – Second binary input array, of shape \(n \times n\). If not passed, distances are computed between rows of X.

Returns:

distances – Array with pairwise Sokal-Sneath distance 2 values. Shape is \(m \times n\) if two arrays are passed, or \(m \times m\) otherwise.

Return type:

ndarray

See also

sokal_sneath_2_binary_distance()

Sokal-Sneath distance 2 function for two vectors

Examples

>>> from skfp.distances import bulk_sokal_sneath_2_binary_distance
>>> import numpy as np
>>> X = np.array([[1, 1, 1], [1, 0, 1]])
>>> Y = np.array([[1, 0, 1], [1, 1, 0]])
>>> dist = bulk_sokal_sneath_2_binary_distance(X, Y)
>>> dist
array([[0.5, 0.5],
       [0. , 0.8]])
>>> X = np.array([[1, 1, 1], [1, 0, 0]])
>>> dist = bulk_sokal_sneath_2_binary_distance(X)
>>> dist
array([[0. , 0.8],
       [0.8, 0. ]])