Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Drawing a map from a table of distances
Give someone the table of driving distances between 30 cities and ask for a map. Multidimensional scaling (MDS) does exactly that: it places points in two or three dimensions so that their distances match the table as closely as possible. The input need not be geographic. It can be how different two sounds seem to listeners, how far apart two failure reports are in wording, or any dissimilarity you can compute.
Many useful dissimilarities have no coordinates behind them: edit distances between log messages, dynamic-time-warping distances between flight trajectories, or expert ratings of how similar two failure modes are. MDS turns such a matrix into a picture you can inspect for clusters and outliers, and into features for downstream methods. Classical MDS is also the core of Isomap and of sensor-network localisation from range measurements.
- 1. MDS needs as input…
- 2. An MDS map is unique up to…
- 3. Nonmetric MDS uses the dissimilarities'…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Classical MDS by hand
From distances to inner products. If the points are centred, squared distances and the Gram matrix B = XXᵀ are related by dᵢⱼ² = bᵢᵢ + bⱼⱼ − 2bᵢⱼ. Inverting this gives the double-centring formula
B = −½ J D⁽²⁾ J, with J = I − 11ᵀ/n,
where D⁽²⁾ holds the squared distances. For the points (0, 0), (3, 0), (0, 4), the centroid is (1, 4/3), so the first centred point is (−1, −4/3) and b₁₁ = 1 + 16/9 = 2.778.
Coordinates. Factor B = VΛVᵀ and take X = V_k Λ_k^½, using the k largest eigenvalues. Two points at distance 5 give B with eigenvalues 12.5 and 0, so the 1-D coordinates are ±2.5.
How good is the fit?
- For Euclidean distances from 2-D points, B has exactly 2 non-zero eigenvalues.
- In general, the fraction of absolute eigenvalue mass in the top k summarises the fit. Eigenvalues 10, 4, 1, −1 give 14/16 = 0.875 for k = 2.
- Stress compares the given dissimilarities δᵢⱼ with the map’s distances dᵢⱼ: √(Σ(δᵢⱼ − dᵢⱼ)²/Σδᵢⱼ²). For δ = (1, 2, 1) among three points and the map 0, 1, 1, stress is √(2/6) = 0.577.
The steps in plain English:
- Build the n × n dissimilarity matrix; for n = 30 that is 435 pairs.
- Double-centre the squared dissimilarities and compute the top eigenvalues; look for negative ones.
- Take the top 2 or 3 eigenvectors scaled by √λ as the classical solution.
- If the dissimilarities are not true Euclidean distances, refine with metric SMACOF, or with nonmetric MDS if only their order is meaningful. Report the stress.
- 1. Double centring turns squared distances into…
- 2. Classical MDS coordinates are…
- 3. A negative eigenvalue of B means the dissimilarities are…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.Classical, metric and nonmetric MDS
Classical MDS = PCA. If D holds Euclidean distances between rows of a data matrix, B is the Gram matrix of the centred data, whose eigenvectors (scaled) are exactly the principal-component scores. Classical MDS minimises strain, ‖B − XXᵀ‖ in Frobenius norm, which weights large distances heavily because it works with squared distances.
Schoenberg’s criterion. A dissimilarity matrix is Euclidean, realisable by points in some ℝᵐ, exactly when B is positive semidefinite. Negative eigenvalues measure how far from Euclidean the data are. Geodesic distances on a curved surface, or a convex transform of distances, typically produce them. A concave transform such as the square root keeps the distances Euclidean, but in more dimensions; in the demo, a square root added positive eigenvalues and no negative ones.
Metric MDS and SMACOF. Minimise raw stress Σ(δᵢⱼ − dᵢⱼ(X))² directly. SMACOF (de Leeuw) majorises the stress by a quadratic and minimises that, giving the Guttman transform: X ← B(X)X/n, where B(X) has off-diagonal entries −δᵢⱼ/dᵢⱼ(X) and rows summing to 0. Each step never increases stress. It converges to a local minimum, so initialise from the classical solution.
Nonmetric MDS. Replace δ by disparities d̂: the best non-decreasing function of δ fitted to the current distances, found by isotonic regression (pool-adjacent-violators). Then take a Guttman step toward d̂ and repeat. The answer depends only on the order of the δ’s.
Exercise 1.
- With exact Euclidean distances between 30 points in 2-D, classical MDS recovered the layout perfectly: Procrustes disparity 0, third eigenvalue of order 10⁻¹⁵ (rounding error).
- Great-circle distances between 40 points on a sphere are not Euclidean: 22.7% of the eigenvalue mass was negative.
- In 2-D, SMACOF lowered the stress from 0.238 (classical) to 0.216. A 3-D SMACOF map reached 0.095, but not 0, because arc lengths are longer than the straight chords any 3-D map can show.
from sklearn.manifold import MDS
X = MDS(n_components=2, dissimilarity="precomputed", metric=False, normalized_stress="auto").fit_transform(D) # nonmetric- 1. For Euclidean distances, classical MDS coincides with…
- 2. Each SMACOF step…
- 3. Nonmetric MDS fits disparities by…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Strain optimality. Among rank-k Gram matrices, VₖΛₖVₖᵀ is the closest to B in Frobenius norm (Eckart–Young), provided the top k eigenvalues are positive. Classical MDS is therefore the exact optimum of strain, not of stress, which explains why SMACOF can improve on it.
Stress landscapes. Stress is non-convex, with local minima, especially in nonmetric MDS and for one-dimensional solutions. Standard practice: start from classical MDS, or use several random starts, and keep the lowest stress. Kruskal’s informal scale for stress-1: about 0.2 poor, 0.1 fair, 0.05 good, 0.025 excellent. It is only a rough guide, because stress grows with n and falls with dimension.
Choosing the dimension. Plot stress against k (a scree plot) and look for an elbow, or inspect the eigenvalues of B.
Scaling up. Classical MDS needs an n × n eigendecomposition. Landmark MDS (de Silva and Tenenbaum) embeds m ≪ n landmarks classically and places the other points by triangulation, costing O(nm). Out-of-sample points are placed the same way.
Interview questions.
- MDS or PCA? If you have feature vectors and Euclidean distance, use PCA: it is the same thing and faster. Use MDS when you only have dissimilarities, or when the distance is not Euclidean.
- Metric or nonmetric? Nonmetric when only the order of the dissimilarities is trustworthy, as with ratings, rankings or similarity scores on an arbitrary scale. Metric when the values themselves are meaningful, such as ranges or travel times.
- 1. Classical MDS exactly minimises…
- 2. Landmark MDS reduces cost by…
- 3. A stress-1 of about 0.05 is conventionally…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.What if the dissimilarities are bent?
History.
- W. Torgerson (1952) gave classical metric scaling, building on G. Young and A. Householder (1938) and on I. Schoenberg’s Euclidean criterion (1935).
- R. Shepard (1962) and J. Kruskal (1964) introduced nonmetric MDS and stress.
- J. de Leeuw (1977) developed the SMACOF majorisation algorithm.
- V. de Silva and J. Tenenbaum (2004) introduced landmark MDS.
Exercise 2. Forty points in a 2-D square, 3 datasets. The dissimilarities are the true distances passed through a monotone function f (identity, square root, or exp(3d) − 1 on distances scaled to [0, 1]), then multiplied by log-normal noise exp(σz). Each cell shows the Procrustes disparity from the true layout (0 = perfect) for classical / metric SMACOF / nonmetric MDS.
| f | σ = 0 | σ = 0.15 |
|---|---|---|
| identity | 0.0000 / 0.0000 / 0.0000 | 0.0212 / 0.0046 / 0.0048 |
| square root | 0.0127 / 0.0077 / 0.0000 | 0.0552 / 0.0186 / 0.0155 |
| exponential | 0.0840 / 0.0218 / 0.0000 | 0.1075 / 0.0241 / 0.0012 |
- Nonmetric MDS was unaffected by the transform when there was no noise: it recovered the layout exactly, because a monotone f does not change the order of the dissimilarities.
- Classical MDS suffered most in every distorted or noisy case. Even with undistorted but noisy distances, it was 4–5 times worse than SMACOF (0.0212 against 0.0046), because squaring amplifies noise on the large distances.
- Metric SMACOF matched nonmetric MDS when f was the identity (0.0046 against 0.0048), so nothing is lost by trusting the values when they are right.
- Noise hurt nonmetric MDS least under the convex exponential and most under the concave square root (0.0012 and 0.0155, against 0.0048 for the identity). Multiplicative noise flips the order of two dissimilarities only when their ratio is close to 1. A convex f with f(0) = 0 makes ratios larger and a concave one makes them smaller, so the convex transform protects the rank order.
MDS in AI, robotics and aerospace
- Sensor-network and swarm localisation: classical MDS on inter-node range measurements gives relative positions, refined by SMACOF and anchored with a few known nodes.
- Trajectory and failure-report maps: embed dynamic-time-warping or text distances to see clusters of similar flights or incidents.
- Perceptual studies: cockpit alarm sounds or display symbols rated for similarity, mapped with nonmetric MDS to find confusable pairs.
References
- W. S. Torgerson (1952). “Multidimensional scaling: I. Theory and method.” Psychometrika 17(4).
- J. B. Kruskal (1964). “Multidimensional scaling by optimizing goodness of fit to a nonmetric hypothesis.” Psychometrika 29(1).
- J. de Leeuw (1977). “Applications of convex analysis to multidimensional scaling.” In Recent Developments in Statistics, North-Holland.
- I. Borg, P. J. F. Groenen (2005). Modern Multidimensional Scaling, 2nd ed. Springer.
- V. de Silva, J. B. Tenenbaum (2004). “Sparse multidimensional scaling using landmark points.” Technical report, Stanford University.