View source: R/metrics.wasserstein.R
wasserstein | R Documentation |
Compute wasserstein distance between two dataset or SparseHist X and Y
wasserstein(X, Y, p = 2, ot = SBCK::OTNetworkSimplex$new())
X |
[matrix or SparseHist] If matrix, dim = ( nrow = n_samples, ncol = n_features) |
Y |
[matrix or SparseHist] If matrix, dim = ( nrow = n_samples, ncol = n_features) |
p |
[float] Power of the metric (default = 2) |
ot |
[Optimal transport solver] |
[float] value of distance
Wasserstein, L. N. (1969). Markov processes over denumerable products of spaces describing large systems of automata. Problems of Information Transmission, 5(3), 47-52.
X = base::cbind( stats::rnorm(2000) , stats::rnorm(2000) )
Y = base::cbind( stats::rnorm(2000,mean=10) , stats::rnorm(2000) )
bw = base::c(0.1,0.1)
muX = SBCK::SparseHist( X , bw )
muY = SBCK::SparseHist( Y , bw )
## The four are equals
w2 = SBCK::wasserstein(X,Y)
w2 = SBCK::wasserstein(muX,Y)
w2 = SBCK::wasserstein(X,muY)
w2 = SBCK::wasserstein(muX,muY)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.