Statistics & probability

Classical multidimensional scaling calculator from pairwise distances

Construct centered coordinates from pairwise distances using classical multidimensional scaling.

Your numbers

3–60 square symmetric rows; nonnegative entries, zero diagonal.
Integer 1–3, below point count and no greater than positive rank.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Construct centered coordinates from pairwise distances using classical multidimensional scaling. Inspect positive and negative eigenvalues, fitted distances and embedding distortion.

THE FORMULAB=−½JD²J; J=I−11ᵀ/n; B=QΛQᵀ; coordinates=Q₊Λ₊¹ᐟ² on the retained positive axes.

A worked example

The four-point matrix contains the distances of a 3 by 4 rectangle, including diagonals 5; two retained axes reconstruct those distances to rounding precision.

Good to know

3–60 points; square nonnegative symmetric distance matrix with zero diagonal; 1–3 requested dimensions below n and within positive rank. Keep positive axes only; report negative inertia and relative distance residual. No missing distances, additive correction or nonmetric stress fit.

Build coordinates from distances rather than features

Classical multidimensional scaling begins with pairwise distances and seeks a centered Euclidean coordinate representation. You do not need the original measured variables. This makes it useful for inspecting a small distance matrix, but it also means that information absent from those distances cannot be recovered by the embedding.

The requested dimension specifies how many positive coordinate axes to retain. The calculator returns the full eigenvalue spectrum, fitted distances and a relative distance residual. These diagnostics distinguish a faithful low-dimensional representation from a picture that discards substantial or inherently non-Euclidean structure.

A rectangle recovered from its pairwise distances1234345Two axes reconstruct every distance
Scroll across to see the full diagram.
The four-point matrix contains the distances of a 3 by 4 rectangle, including diagonals 5; two retained axes reconstruct those distances to rounding precision.

Compare this with the Principal component analysis calculator from a data matrix. Construct Euclidean coordinates from a distance matrix and diagnose negative eigenvalues,without requiring the original feature matrix.

Check the distance matrix before interpreting a map

Rows and columns must refer to the same points in the same order. Distances must be nonnegative and symmetric, and every diagonal entry must be zero. A transposed label order or a small copied diagonal value can change the problem rather than merely perturbing a cosmetic part of the display.

The supported matrix contains three to sixty points, with one to three requested dimensions below the number of points. The calculator does not infer missing distances or convert similarities automatically. A similarity score needs an explicitly chosen distance transformation before this Euclidean distance-based method can be applied.

Double centering creates the Gram matrix

The algorithm squares the distances and removes row and column means while adding the grand mean. Multiplying that centered matrix by minus one half produces a candidate inner-product matrix. Its positive eigenvalues and corresponding eigenvectors supply the retained Euclidean coordinate axes.

For genuinely Euclidean input, this matrix is positive semidefinite apart from rounding error. A coordinate axis uses the eigenvector multiplied by the square root of its eigenvalue. The resulting points have their centroid at zero because distances identify relative geometry without identifying an absolute origin in space.

The example reconstructs a rectangle

The four prefilled points have adjacent distances three and four and opposite-corner distances five. These are the distances of a three-by-four rectangle. Requesting two dimensions reproduces those pairwise distances to floating-point precision even if the returned rectangle is reflected or its axes are exchanged.

The two positive eigenvalues measure spread along its orthogonal directions. Their signs and magnitudes are geometric diagnostics, while the sign of an individual eigenvector is arbitrary. Compare fitted distances when validating another implementation rather than requiring every printed coordinate to have the same orientation.

Negative eigenvalues diagnose a different geometry

A substantial negative eigenvalue means the submitted dissimilarities cannot all be represented exactly as ordinary Euclidean distances in any dimension. Keeping only positive directions still produces coordinates, but it changes the target geometry. The result therefore reports the total magnitude of negative eigenvalues and a non-Euclidean warning.

Tiny negative values can arise from numerical rounding and are interpreted relative to the largest spectral magnitude. This implementation does not add a Cailliez constant, apply a square-root transformation or run nonmetric stress minimization. Those alternatives solve modified problems and should be chosen deliberately rather than applied invisibly.

Use the residual in the original distance scale

The relative distance residual is the square root of the sum of squared differences between submitted and fitted distances divided by the sum of squared submitted distances. It directly measures how much the retained coordinate distances differ from the original matrix, including both omitted positive directions and non-Euclidean effects.

Retained positive inertia is a different diagnostic: it is the sum of retained positive eigenvalues divided by the sum of all positive eigenvalues. A high inertia fraction can coexist with meaningful distance distortion when negative eigenvalues are substantial. Read these quantities together rather than substituting one percentage for the other.

Keep the embedding descriptive

A coordinate map summarizes the relationships supplied to it and does not discover a causal ordering or meaningful named latent trait by itself. Axis names require domain interpretation. Distances between points in the map are in the input distance units when the embedding is exact, despite arbitrary translations or rotations.

Repeated points are allowed when their zero distances are consistent with the rest of the matrix, but the requested dimension must still have enough positive eigenvalues. A rank-deficient matrix can be valid in fewer dimensions. Reduce the dimension after an informative rank error instead of inserting artificial distances to manufacture another axis.

A few questions, answered

Can coordinates rotate or reflect?

Yes. Pairwise distances do not identify an absolute orientation.

What do negative eigenvalues mean?

Substantial negatives show the dissimilarities are not exactly Euclidean.

Is the distance residual the same as inertia retained?

No. One compares original and fitted distances; the other summarizes retained positive spectral spread.

Can missing distances be entered?

No. A complete symmetric matrix is required.

Find your calculator

Start typing to explore the library.