cupyx.scipy.spatial.distance.pdist(X, metric='euclidean', *, out=None, **kwargs)[source]#

Compute distance between observations in n-dimensional space.

  • X (array_like) – An \(m\) by \(n\) array of \(m\) original observations in an \(n\)-dimensional space. Inputs are converted to float type.

  • metric (str, optional) – The distance metric to use. The distance function can be ‘canberra’, ‘chebyshev’, ‘cityblock’, ‘correlation’, ‘cosine’, ‘euclidean’, ‘hamming’, ‘hellinger’, ‘jensenshannon’, ‘kl_divergence’, ‘matching’, ‘minkowski’, ‘russellrao’, ‘sqeuclidean’.

  • out (cupy.ndarray, optional) – The output array. If not None, the distance matrix Y is stored in this array.

  • **kwargs (dict, optional) – Extra arguments to metric: refer to each metric documentation for a list of all possible arguments. Some possible arguments: p (float): The p-norm to apply for Minkowski, weighted and unweighted. Default: 2.0


A \(m\) by \(m\) distance matrix is returned. For each \(i\) and \(j\), the metric dist(u=X[i], v=X[j]) is computed and stored in the \(ij\) th entry.

Return type

Y (cupy.ndarray)