TOPICS
Search

Distance Matrix


For an ordered list X=(x_1,...,x_n) in a metric space with metric d, the distance matrix of X is the square matrix

 D_X=(d_(ij))=(d(x_i,x_j))_(i,j=1)^n.
(1)

It is symmetric, has zero diagonal and nonnegative entries, and its entries obey the triangle inequality d_(ij)<=d_(ik)+d_(kj). Conversely, any matrix with these properties and with d_(ij)=0 iff i=j defines a metric on its index set. A dissimilarity matrix need not satisfy all of these conditions.

Suppose x_1, ..., x_n are points in a Euclidean space. The matrix of their squared distances,

 Delta=(delta_(ij))=(||x_i-x_j||^2)_(i,j=1)^n,
(2)

is commonly called a squared Euclidean distance matrix, or sometimes simply a Euclidean distance matrix. Let 1 be the all-ones vector and define

J=I-1/n11^T
(3)
B=-1/2JDeltaJ.
(4)

Then B is the gram matrix of the points after translating their centroid to the origin. A symmetric matrix Delta with zero diagonal is a squared Euclidean distance matrix iff B is positive semidefinite; equivalently, z^TDeltaz<=0 whenever z^T1=0 (Schoenberg 1935). The smallest Euclidean dimension in which the distances can be realized is rank(B) (Young and Householder 1938). If D=(d_(ij)) contains unsquared Euclidean distances, these criteria are applied to Delta=(d_(ij)^2).

A graph distance matrix is the distance matrix obtained from the graph distances among the vertices of a graph. Distance matrices also serve as input to multidimensional scaling and other methods that reconstruct or approximate point configurations from pairwise distances.

The distance matrix of a list of objects can be computed in the Wolfram Language using DistanceMatrix[{x1, ..., xn}], with the metric specified by the DistanceFunction option when needed.


See also

Graph Distance Matrix, Gram Matrix, Metric Space, Multidimensional Scaling, Positive Semidefinite Matrix

Explore with Wolfram|Alpha

References

Dokmanić, I.; Parhizkar, R.; Ranieri, J.; and Vetterli, M. "Euclidean Distance Matrices: Essential Theory, Algorithms, and Applications." IEEE Signal Process. Mag. 32, 12-30, 2015. https://doi.org/10.1109/MSP.2015.2398954.Schoenberg, I. J. "Remarks to Maurice Fréchet's Article 'Sur la Définition Axiomatique d'une Classe d'Espaces Vectoriels Distanciés Applicables Vectoriellement sur l'Espace de Hilbert.' " Ann. Math. 36, 724-732, 1935. https://doi.org/10.2307/1968654.Young, G. and Householder, A. S. "Discussion of a Set of Points in Terms of Their Mutual Distances." Psychometrika 3, 19-22, 1938. https://doi.org/10.1007/BF02287916.

Referenced on Wolfram|Alpha

Distance Matrix

Cite this as:

Weisstein, Eric W. "Distance Matrix." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/DistanceMatrix.html

Subject classifications