Notes

Wasserstein Distance

Imagine comparing two piles of sand: not just asking whether they contain the same amount, but how much work it would take to reshape one pile into the other. That is the intuition behind Wasserstein Distance. It measures how different two probability distributions are by asking how much “mass” must be moved, and how far, to turn one distribution into the other.

What it measures

Technically, Wasserstein Distance is a distance between distributions, not just between individual data points. It comes from optimal transport. If one distribution places probability mass in different locations than another, the Wasserstein distance computes the minimum total transport cost needed to align them. That cost depends on both how much mass moves and the distance it travels. This makes it especially useful when two distributions do not overlap much, because it still gives a meaningful notion of closeness instead of collapsing into an uninformative result.

Why it matters in unsupervised learning

Many unsupervised tasks compare whole distributions rather than single observations. Wasserstein distance is valuable because it respects the geometry of the data space.

  • In generative modeling, it is central to Wasserstein GANs (WGANs), where it gives a smoother training signal than divergences like KL or Jensen-Shannon.
  • In clustering distributions, it can compare customer behavior profiles, document topic mixtures, or image histograms.
  • In anomaly detection, it can flag a batch of transactions whose distribution has shifted from normal behavior.

Practical use

A common simple case is the 1D Wasserstein distance, available in scipy.stats.wasserstein_distance. You might use it to compare purchase amounts from two customer segments, or pixel intensity distributions from compressed versus original images. In higher dimensions, computation becomes more expensive, so practitioners use approximations such as Sinkhorn distance, which adds regularization to make transport faster to compute. The key idea stays the same: Wasserstein distance captures not just whether distributions differ, but how that difference is arranged in space.

Wasserstein Distance is a measure of dissimilarity between two probability distributions defined by the minimum “cost” of transporting mass from one distribution to match the other. Unlike divergences that fail on non-overlapping supports, it reflects both probability mismatch and geometric distance in the underlying space. In unsupervised learning, Wasserstein Distance matters because it provides a stable, meaningful objective for comparing distributions in clustering, density estimation, and generative modeling.

Imagine two piles of sand shaped differently on a table. Wasserstein Distance asks: how much work would it take to move the sand from one pile so it matches the other? If the piles are already similar, only a little moving is needed. If they are very different, it takes more effort.

In AI, this is a way to compare two distributions—meaning two overall patterns of data, not just single points. That matters in unsupervised learning, where systems often try to understand or generate patterns without labeled answers. Wasserstein Distance is useful because it captures not just whether two patterns differ, but how far apart they are in a meaningful, intuitive way.