where \(\bar{v}\) is the mean of the elements of vector v,
and \(x \cdot y\) is the dot product of \(x\) and \(y\).

Y=cdist(XA,XB,'hamming')

Computes the normalized Hamming distance, or the proportion of
those vector elements between two n-vectors u and v
which disagree. To save memory, the matrix X can be of type
boolean.

Y=cdist(XA,XB,'jaccard')

Computes the Jaccard distance between the points. Given two
vectors, u and v, the Jaccard distance is the
proportion of those elements u[i] and v[i] that
disagree where at least one of them is non-zero.

Y=cdist(XA,XB,'chebyshev')

Computes the Chebyshev distance between the points. The
Chebyshev distance between two n-vectors u and v is the
maximum norm-1 distance between their respective elements. More
precisely, the distance is given by

\[d(u,v) = \max_i {|u_i-v_i|}.\]

Y=cdist(XA,XB,'canberra')

Computes the Canberra distance between the points. The
Canberra distance between two points u and v is

\[d(u,v) = \sum_i \frac{|u_i-v_i|}
{|u_i|+|v_i|}.\]

Y=cdist(XA,XB,'braycurtis')

Computes the Bray-Curtis distance between the points. The
Bray-Curtis distance between two points u and v is

\[d(u,v) = \frac{\sum_i (|u_i-v_i|)}
{\sum_i (|u_i+v_i|)}\]

Y=cdist(XA,XB,'mahalanobis',VI=None)

Computes the Mahalanobis distance between the points. The
Mahalanobis distance between two points u and v is
\(\sqrt{(u-v)(1/V)(u-v)^T}\) where \((1/V)\) (the VI
variable) is the inverse covariance. If VI is not None,
VI will be used as the inverse covariance matrix.

Computes the distance between all pairs of vectors in X
using the user supplied 2-arity function f. For example,
Euclidean distance between the vectors could be computed
as follows:

dm=cdist(XA,XB,lambdau,v:np.sqrt(((u-v)**2).sum()))

Note that you should avoid passing a reference to one of
the distance functions defined in this library. For example,:

dm=cdist(XA,XB,sokalsneath)

would calculate the pair-wise distances between the vectors in
X using the Python function sokalsneath. This would result in
sokalsneath being called \({n \choose 2}\) times, which
is inefficient. Instead, the optimized C version is more
efficient, and we call it using the following syntax: