pub fn sliced_wasserstein(
a: &[f64],
b: &[f64],
centroids: &[&[f32]],
n_projections: usize,
seed: u64,
) -> f64Expand description
Sliced Wasserstein distance between two distributions in K dimensions.
Approximates the true Wasserstein distance by projecting both distributions onto random 1D lines and computing the exact W₁ on each projection. The average over projections converges to the Sliced Wasserstein distance.
§Arguments
a- First distribution: weights over K bins (must sum to ~1.0).b- Second distribution: same K bins.centroids- K centroid vectors (one per bin). Used for projection.n_projections- Number of random 1D projections (more = more accurate).seed- Random seed for reproducibility.
§Complexity
O(n_proj × K × (D + K log K)) where D = centroid dimensionality.