MagGN · magnitude distance · interactive figure

Magnitude Distance Explorer

X stands in for a batch of real data and Y for a batch from a generator. Drag Y across the plane, change the scale t or break the generator, and the normalized magnitude distance that MagGN minimises is recomputed in your browser with the same formula as magnitude.py.

t= 5.00 scale · similarity e−t‖x−y‖ Starting…
0.1110100
Values used in the project
Points per set (batch size) 128
Spread of Y relative to X 1.00×
Real data X
Generator Y
Plotted distance

Real and generated batches

Drag anywhere to move Y. Point size shows each point's weight in |X ∪ Y|t.

Real X Generated Y low → high weight μ = (0.00, 0.00)

Distance across scales

The same two batches, every t from 0.1 to 100

Distance as Y slides away

Y translated along the current shift direction, one curve per t

At this scale

|·|t = sum of the entries of S−1, the effective number of distinct points

What the distance measures

Magnitude counts how many distinct points a set has at scale t. If Y lands on top of X, the union adds almost nothing, so |X ∪ Y| ≈ |X| and the distance falls to the sampling floor. If Y sits far away, the union counts both, |X ∪ Y| ≈ |X| + |Y|, and the normalized distance reaches 1.

Why the loss uses several t

Small t sees coarse layout and saturates once the batches are apart. Large t sees individual modes but is near 1 for any two different samples. The toy MagGN run averages t = 5, 20 and 50 so the generator gets a gradient at every stage. Try mode dropping on 8 Gaussians to see which scales notice.

How it is computed

The page builds S = exp(−t·D) for X, Y and X ∪ Y, factors each with a float64 Cholesky and sums S⁻¹1. Training uses eps = 0; when a matrix is too close to singular (tight clusters at small t) the page adds the smallest jitter that works and says so.

Distance: norm_diff_magnitude_distance_grad(X, Y, t, normalize=True) = (2|X∪Y|t − |X|t − |Y|t) / |X∪Y|t. Datasets follow Toy_Experiment/data_generator.py; multiscale schedule from MagGN_toy_experiments.ipynb. Points are sampled in the browser with a fixed seed, not loaded from training runs. From “Magnitude Distance: A Geometric Measure of Dataset Similarity”, ICML 2026.