TL;DR
Matching two sets of points on a 1D line is trivially fast if you match everything: just sort and pair them up in order. But if your data has outliers and you only want to match subsets of points (partial optimal transport), the math gets tricky, forcing existing algorithms into a sluggish quadratic bottleneck whenever distances are squared or raised to higher powers ($p > 1$). This paper breaks that quadratic barrier using a clever marriage of range trees and Fast Fourier Transforms (FFTs), computing all optimal partial matchings in near-linear time.
What Problem Does This Paper Address?
Optimal transport (specifically, the $p$-Wasserstein distance) measures the cheapest way to move probability mass from one distribution to another, where moving a unit from $a$ to $b$ costs $|a - b|^p$. While high-dimensional transport is computationally heavy, 1D transport is so fast—just $O(n \log n)$ via sorting—that many machine learning methods project high-dimensional data onto random 1D lines ("sliced Wasserstein") to scale up.
Real-world data, however, is messy and full of outliers. Instead of matching 100% of the data, we often want the Optimal Transport profile (OT-profile): the minimum cost of matching $k$ pairs of points for every $k$ from $1$ to $n$.
For $p=1$, you can compute this entire profile in $O(n \log n)$ time because you can add new matched pairs greedily without undoing previous ones. For $p > 1$ (like standard squared Euclidean cost, $p=2$), convexity ruins this neat trick. Adding just one new pair of points can force every single previously matched edge to shift over. Across all $n$ steps, $\Theta(n^2)$ distinct edges appear, trapping explicit matching algorithms in $\Theta(n^2)$ time. The authors ask: is this quadratic wall fundamental, or can we bypass it?
Methods
The authors combine a classic algorithmic framework with a brand-new data structure:
- Standard Framework (1D Hungarian Algorithm): Building on recent work, they grow the matching one pair at a time. Instead of storing individual edges—which shift constantly—they represent the current matching implicitly as a set of disjoint balanced intervals (segments containing equal numbers of red and blue points). Within any balanced interval, points are implicitly matched in sorted order. Adding a new pair simply merges or updates adjacent intervals using a priority queue.
- What’s New (FFT-Augmented Range Tree): To pick the best next pair of free points, the algorithm must quickly ask: "What is the exact $p$-Wasserstein cost of matching all points inside this balanced interval?" Doing this naively takes linear time per query. Instead, the authors build a binary range tree over the sorted points. Because points inside a balanced interval are matched in order, every matched pair $(r_j, b_{j+d})$ shares a constant index offset, or shift $d$.
Computing the costs for all possible shifts at every tree node looks quadratic at first glance. Here comes the magic trick: for integer $p$, they algebraically expand $(b_{j+d} - r_j)^p$ using the binomial theorem. This turns the sum of costs for each shift into a discrete convolution of point-coordinate powers, which they precompute simultaneously across the tree using Fast Fourier Transforms (FFT). Queries then take just $O(\log n)$ time by summing precomputed shift values across $O(\log n)$ tree nodes.
Datasets
No real-world benchmarks were used; the authors evaluate their C++ implementation (FFTHungarian) on synthetic 1D point sets of sizes $n = 10^2$ to $10^7$ drawn from continuous distributions with varying overlap:
- Variance perturbations: $\mathcal{N}(0, 1^2)$ vs. $\mathcal{N}(0, \sigma^2)$ for $\sigma \in \{1, 1.01, 1.1, 2\}$.
- Mean perturbations: $\mathcal{N}(0, 1^2)$ vs. $\mathcal{N}(\mu, 1^2)$ for $\mu \in \{0, 0.01, 0.1, 1\}$.
- Bimodal perturbations: $\mathcal{N}(0, 1^2)$ vs. an equal mixture $\frac{1}{2}\mathcal{N}(-\mu, 1^2) + \frac{1}{2}\mathcal{N}(\mu, 1^2)$.
Key Insights and Ideas
- Implicit beats explicit: Even though the sequence of optimal matchings from $k=1$ to $n$ contains $\Theta(n^2)$ unique edges, you never have to write them down. Representing matchings as balanced intervals compresses the state space to $O(n)$ and requires only a handful of interval merges per step.
- Polynomial expansion unlocks FFT: Absolute differences $|a - b|^p$ normally resist algebraic tricks. By separating left-to-right and right-to-left crossings inside a range tree node, the signs become fixed, letting binomial expansion turn geometric transport costs into fast polynomial multiplication.
- A sharp complexity cliff at $p = \infty$: While every finite integer $p$ yields to near-linear time, the bottleneck case ($p = \infty$, minimizing the maximum matched distance) hits a wall. The authors prove it is computationally equivalent (up to log factors) to $(\min, +)$-convolution—a notoriously hard problem in fine-grained complexity with no known near-linear algorithm.
Key Results
- Theoretical Speedup: Computes all $k$-partial $p$-Wasserstein costs for any integer $p \in \mathbb{N}$ in $O(p\, n \log^2 n)$ time and $O(n \log n)$ space, breaking the $\Omega(n^2)$ barrier.
- Practical Speedup: Tested at $p=2$ against the state-of-the-art optimized baseline (
PAWL),FFTHungarianis significantly faster whenever $n \ge 10,000$ and the two distributions are not identical. Even with a tiny 10% difference in mean or standard deviation,PAWLdegrades toward quadratic time (hitting a 60-second timeout well before $n = 10^7$), whereasFFTHungarianscales near-linearly and finishes orders of magnitude faster. - Lower Bound Equivalence: Proves that solving the $p=\infty$ OT-profile in $\widetilde{O}(n^{2-\varepsilon})$ time is possible if and only if $(\min, +)$-convolution can be solved in $\widetilde{O}(n^{2-\varepsilon})$ time (where the fastest currently claimed Lean-verified bound sits around $O(n^{1.9602})$).
Limitations and Future Work
- Integer $p$ and Uniform Weights: The binomial expansion trick relies on $p$ being a finite positive integer ($p \in \mathbb{N}$), leaving fractional $p > 1$ unaddressed. Furthermore, the algorithm assumes discrete distributions supported on $n$ points with uniform mass ($1/n$ each), rather than arbitrary point weights.
- The $p = \infty$ Bottleneck: Near-linear time does not extend to $p = \infty$ unless a major breakthrough occurs in $(\min, +)$-convolution.
- Two-Interval Queries: As noted in their appendix results, generalizing the data structure to query transport between two separate intervals $I_B$ and $I_R$ (rather than a single shared interval $I$) runs into combinatorial Boolean matrix multiplication hardness.
Summary updated