Pairwise distances between observations in ndimensional space.
The following are common calling conventions.
Y = pdist(X, 'euclidean')
Computes the distance between m points using Euclidean distance (2norm) as the distance metric between the points. The points are arranged as m ndimensional row vectors in the matrix X.
Y = pdist(X, 'minkowski', p)
Computes the distances using the Minkowski distance (pnorm) where .
Y = pdist(X, 'cityblock')
Computes the city block or Manhattan distance between the points.
Y = pdist(X, 'seuclidean', V=None)
Computes the standardized Euclidean distance. The standardized Euclidean distance between two nvectors u and v is
V is the variance vector; V[i] is the variance computed over all the i’th components of the points. If not passed, it is automatically computed.
Y = pdist(X, 'sqeuclidean')
Computes the squared Euclidean distance between the vectors.
Y = pdist(X, 'cosine')
Computes the cosine distance between vectors u and v,
where is the 2norm of its argument *, and is the dot product of u and v.
Y = pdist(X, 'correlation')
Computes the correlation distance between vectors u and v. This is
where is the mean of the elements of vector v, and is the dot product of and .
Y = pdist(X, 'hamming')
Computes the normalized Hamming distance, or the proportion of those vector elements between two nvectors u and v which disagree. To save memory, the matrix X can be of type boolean.
Y = pdist(X, '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 nonzero.
Y = pdist(X, 'chebyshev')
Computes the Chebyshev distance between the points. The Chebyshev distance between two nvectors u and v is the maximum norm1 distance between their respective elements. More precisely, the distance is given by
Computes the Canberra distance between the points. The Canberra distance between two points u and v is
Computes the BrayCurtis distance between the points. The BrayCurtis distance between two points u and v is
Computes the Mahalanobis distance between the points. The Mahalanobis distance between two points u and v is where (the VI variable) is the inverse covariance. If VI is not None, VI will be used as the inverse covariance matrix.
Computes the Yule distance between each pair of boolean vectors. (see yule function documentation)
Computes the matching distance between each pair of boolean vectors. (see matching function documentation)
Computes the Dice distance between each pair of boolean vectors. (see dice function documentation)
Computes the Kulsinski distance between each pair of boolean vectors. (see kulsinski function documentation)
Computes the RogersTanimoto distance between each pair of boolean vectors. (see rogerstanimoto function documentation)
Computes the RussellRao distance between each pair of boolean vectors. (see russellrao function documentation)
Computes the SokalMichener distance between each pair of boolean vectors. (see sokalmichener function documentation)
Computes the SokalSneath distance between each pair of boolean vectors. (see sokalsneath function documentation)
Computes the weighted Minkowski distance between each pair of vectors. (see wminkowski function documentation)
Computes the distance between all pairs of vectors in X using the user supplied 2arity function f. For example, Euclidean distance between the vectors could be computed as follows:
dm = pdist(X, lambda u, v: np.sqrt(((uv)**2).sum()))Note that you should avoid passing a reference to one of the distance functions defined in this library. For example,:
dm = pdist(X, sokalsneath)would calculate the pairwise distances between the vectors in X using the Python function sokalsneath. This would result in sokalsneath being called times, which is inefficient. Instead, the optimized C version is more efficient, and we call it using the following syntax.:
dm = pdist(X, 'sokalsneath')
Parameters :  X : ndarray
metric : string or function
w : ndarray
p : double
V : ndarray
VI : ndarray


Returns :  Y : ndarray

See also
Notes
See squareform for information on how to calculate the index of this entry or to convert the condensed distance matrix to a redundant square matrix.