Loading…
Loading…
Recover coordinates from pairwise distances through double centering, test Euclidean embeddability, and distinguish classical MDS from ordinal stress fitting.
Some datasets describe relations between objects rather than measurements of their features. We may know how far apart every pair of objects is without knowing a useful coordinate system for them. Multidimensional scaling asks how to turn those pairwise relations into positions in a low-dimensional Euclidean space. Classical MDS reconstructs inner products from squared distances; non-metric MDS instead fits the order of dissimilarities through a monotone transformation. Their objectives express different meanings of a good map.
PCA starts with a table of feature vectors and finds directions in their feature space. MDS starts with a square table whose entries compare pairs of objects. A row of that table lists relations to the other objects, not a vector of measured features. Applying PCA directly to those rows would therefore solve a different problem from reproducing the supplied distances.
Let , with . The target is a coordinate matrix : row stores the point . We want the Euclidean distances between rows to express the pairwise information in . Typical maps use one or two coordinates, but the algebra also identifies how many coordinates exact reconstruction needs.
A distance table cannot determine an absolute origin. Adding the same vector to every row preserves all differences between points. We therefore choose the centered representative, whose column means vanish. An origin is fixed by this choice; an orientation remains free.
Definition
A dissimilarity table here is symmetric, nonnegative, and hollow: and . A metric additionally separates distinct objects and satisfies for every triple. A table is Euclidean if some points satisfy
Coincident points are allowed in this last definition; they produce zero distance between their labels. The triangle inequality alone does not characterize Euclidean distance tables.
For classical MDS, square each entry separately and define the centering matrix:
Thus is not the matrix product . The matrix is symmetric, , and . Multiplication subtracts the coordinate mean from each row. Define row means and the grand mean of by
These are means of squared distances, rather than means of distances. Because is symmetric, its column means equal its row means. Double centering subtracts both sets of means and adds back the grand mean once.
Theorem
For a symmetric, nonnegative, hollow table , set
Then is Euclidean exactly when is positive semidefinite. When this holds, its positive eigendecomposition gives centered coordinates
The smallest exact embedding dimension is , at most . A zero-rank table describes coincident points.
Proposition
Order the eigenvalues of from largest to smallest. Among centered positive semidefinite Gram matrices of rank at most , the minimum of is attained by retaining the largest at most positive eigenvalues. If indexes those retained values, then
Negative eigenvalues contribute unavoidable error to this positive Gram approximation. Repeated eigenvalues can give several equally good coordinate orientations or retained subspaces.
The discrepancy in the second statement is often called classical strain. It compares inner products, so it is distinct from the sum of squared errors in the pairwise distances themselves. A low-dimensional classical map optimizes this Gram criterion; interpreting its coordinates still requires examining the distances and the discarded spectrum.
Suppose centered coordinates exist. Their Gram matrix is , with . The distance identity gives
Let . In matrix form this identity reads . Multiplying on both sides by removes the first two terms because . Centering gives , so . Hence , proving the formula using only the distance table. The entrywise mean formula is precisely the expansion of this matrix product.
Proof
If coordinates exist, then for every , so is positive semidefinite. Conversely, assume that the constructed is positive semidefinite and factor it spectrally as . Since , every positive-eigenvalue eigenvector is perpendicular to ; the resulting coordinate columns have mean zero.
The hollow diagonal of implies . Therefore
The recovered points reproduce the squared distances, and nonnegativity of recovers the distances themselves. A Gram matrix of coordinates in dimensions has rank at most , while the factor above uses exactly one column per positive eigenvalue. This proves the minimum-dimension claim.
For the truncation result, orthogonal invariance of the Frobenius norm allows the comparison in an eigenbasis of . The spectral low-rank approximation principle assigns available nonnegative eigenvalues to the largest positive directions; in each selected direction the best value is . Unselected directions contribute their squared eigenvalues. Every retained positive direction is centered because it is orthogonal to .
Centered coordinates have a remaining geometric ambiguity. For an orthogonal matrix , the matrix has the same Gram matrix and the same pairwise distances. Rotations, reflections, and changes of eigenvector sign consequently produce equally valid maps. A meaningful comparison uses relative positions and distances, rather than the sign of a plotted axis.
Worked example
Take
The squared-distance row means are , , and , with grand mean . Double centering gives
This matrix equals for . Its only positive eigenvalue is . Consequently one coordinate suffices:
The coordinate mean is zero, and the three pairwise distances are , , and in their prescribed positions. Adding to each coordinate gives , , and ; reflection gives another valid arrangement. These changes illustrate the translation and orientation information that a distance table does not contain.
The negative off-diagonal entries of are ordinary negative inner products. They do not contradict positive semidefiniteness, which is a condition on quadratic forms or eigenvalues rather than the signs of individual entries.
Worked example
Let record shortest-path distances around a cycle of four unit edges:
The triangle inequality holds: an opposite pair is distance , reached by two adjacent edges of length , and no alternate path is shorter than the shortest path. Nevertheless the eigenvalues of are , , , and . For example, is an eigenvector with eigenvalue . The exact Euclidean criterion therefore fails in every dimension.
Retaining the two positive directions gives coordinates
Opposite distances remain , while adjacent distances become . The minimum squared Gram discrepancy is . The negative direction records a genuine obstruction to the requested geometry; it is not an extra Euclidean coordinate whose square root could be added. The approximation replaces that geometry by a positive Gram matrix and visibly changes some distances.
Worked example
For three objects, prescribe dissimilarities , , and . They violate the triangle inequality because . Their strict order can nevertheless be represented by the one-dimensional coordinates , , and , whose corresponding distances are , , and .
A monotone transformation can take
Join these values with increasing line segments if a function between the observed dissimilarities is required. Every transformed dissimilarity equals its fitted Euclidean distance. The normalized stress defined below is zero, with positive denominator .
The map captures the ranking perfectly, even though the input value is not reproduced. This is exactly the information an ordinal objective chooses to retain. The numerical gaps between successive dissimilarities are free to change, so zero ordinal stress is a different conclusion from exact classical distance reconstruction.
The following calculation implements Example 1 with symmetric eigenvalue decomposition. The explicit elementwise square distinguishes the input distances from the Gram construction. A small positive threshold separates the zero eigenvalues in this example from floating-point roundoff.
import numpy as np
D = np.array([[0, 1, 3], [1, 0, 2], [3, 2, 0]], dtype=float)
n = D.shape[0]
H = np.eye(n) - np.ones((n, n)) / n
E = D ** 2
B = -0.5 * H @ E @ H
eigenvalues, eigenvectors = np.linalg.eigh(B)
order = np.argsort(eigenvalues)[::-1]
eigenvalues = eigenvalues[order]
eigenvectors = eigenvectors[:, order]
selected = np.flatnonzero(eigenvalues > 1e-10)[:1]
X = eigenvectors[:, selected] * np.sqrt(eigenvalues[selected])
fitted = np.linalg.norm(X[:, None, :] - X[None, :, :], axis=2)
print(np.round(eigenvalues, 6))
print(np.round(fitted, 6))
The eigenvalues are approximately , , and ; the reconstructed distance matrix equals up to numerical precision. A returned coordinate column may have the opposite sign from the hand calculation. When inspecting another dataset, examine the negative spectrum before truncating it: the size of a substantive negative eigenvalue measures information discarded by the positive Gram approximation.
Suppose the feature measurements are available after all. Let be their centered matrix, and form from Euclidean distances between its rows. The derivation above then yields
Here the last expression is precisely the leading PCA score matrix. Classical MDS and PCA consequently produce the same reduced configuration when they start with this same Euclidean geometry. One starts from distances and the other from features; the common object is the centered inner-product structure. Signs and rotations within repeated eigenspaces can change the displayed coordinate axes while preserving that structure.
The eigenvalues in this Gram matrix are squared singular values, rather than sample covariance eigenvalues. Sample covariance divides by . Taking square roots of those covariance eigenvalues as MDS coordinate scales would shrink every distance by a factor of . Retaining the correct normalization matters when a map must reproduce given numerical distances.
The same comparison helps interpret dimension reduction. Discarding a positive eigenvalue removes a direction that the complete Euclidean data actually possess. Discarding a negative eigenvalue removes a direction that cannot belong to any real Euclidean Gram factor in the first place. These two sources of approximation enter the strain sum together, but represent different geometric reasons for a mismatch. Inspecting their contributions separately explains whether an inaccurate map mainly reflects the chosen dimension or the non-Euclidean structure of the input relations.
Definition
For fitted distances , choose a nondecreasing function of the observed dissimilarities. The values are called disparities. The normalized stress used here is
Equal input dissimilarities receive equal disparities under this function convention. Distinct inputs may receive tied disparities because nondecreasing functions can have flat portions.
With fixed, the denominator is constant. Sort the observed pairs by their dissimilarities and fit their current Euclidean distances with a nondecreasing sequence. This is isotonic regression. If successive fitted values violate the ordering, pooling a block replaces its values by their average in the unweighted least-squares step. Tied inputs are treated as one disparity level.
With disparities fixed, change the coordinates to reduce the chosen stress. The coordinate problem is nonconvex, so initialization and the progress of this step affect the attained configuration. Alternating the two steps describes an optimization scheme; a stopping criterion terminates that scheme without establishing a global optimum. In particular, small stress measures closeness to monotone disparities, rather than certifying every strict order between fitted distances.
The positive-denominator condition excludes a completely collapsed configuration, where every point is identical and this ratio is undefined. For , replacing by leaves stress unchanged. A numerical scheme may therefore fix an overall scale as well as center its coordinates. These choices remove irrelevant location and scale freedoms while leaving the ordinal comparison intact.
Common mistake
Square the entries of before double centering. Test positive semidefiniteness of the resulting Gram matrix, rather than requiring its entries to be nonnegative. A valid metric can still have an indefinite centered Gram matrix. Classical truncation, raw-distance fitting, and ordinal stress compare different objects, so their numerical errors are not interchangeable.
Classical MDS turns squared pairwise distances into a centered Gram matrix. Its spectrum decides exact Euclidean embeddability and supplies coordinates or a positive low-rank approximation. Non-metric MDS instead compares fitted distances with a monotone transformation of dissimilarities. Centering fixes translation; orthogonal changes preserve classical geometry, and a joint positive scaling of coordinates and disparities preserves normalized ordinal stress.
Checkpoint
Use the hollow matrix with off-diagonal entries and square those entries before centering.
Checkpoint
Separate the Euclidean criterion from the rank-one approximation criterion.
Checkpoint
In increasing dissimilarity order, the current distances are , , . Pool the violating adjacent block.
The mean squared-distance row value and grand mean both equal , giving
Its eigenvalues are and . Coordinates have mean zero, Gram matrix , and distance . The positive rank is one.
The negative eigenvalue prevents exact Euclidean reconstruction in any dimension. The rank-one positive approximation retains . Its squared Gram discrepancy is . The retained coordinate column is times a unit eigenvector for the eigenvalue .
The first two distances violate the required nondecreasing order. Their least-squares pooled value is , while the third disparity remains . Thus
The flat fitted block is permitted by nondecreasing isotonic regression. It does not remove the distance inversion while the coordinates remain fixed; the subsequent coordinate step addresses that remaining mismatch.
SVD and principal components introduces centering and spectral coordinates from measured features. Centered kernels and kernel PCA starts from inner products in a feature space. Fisher discriminants and class scatter uses class labels to choose projection directions. The course reading list collects the course books.