Sliced Wasserstein Distance Between Two Empirical Distributions
Source:R/sliced_wasserstein.R
sliced_wasserstein.RdEstimate the sliced Wasserstein distance between two empirical distributions represented as matrices using Monte Carlo simulation.
Optionally, a matrix thetas can be supplied. Each row of thetas will
be interpreted as a projection direction. These rows do not have to be
unit vectors, allowing users to transform the projection directions
rather than the matrices.
Examples
M1 <- matrix(rnorm(50), ncol = 5)
M2 <- matrix(rnorm(250), ncol = 5)
sliced_wasserstein(M1, M2) # random projection directions
#> [1] 0.6550946
cardinal_axes <- diag(1, 5)
sliced_wasserstein(M1, M2, thetas = cardinal_axes)
#> [1] 0.5931266
first_two_axes <- cardinal_axes[1:2, ]
sliced_wasserstein(M1, M2, thetas = first_two_axes)
#> [1] 0.6565441