Samples S
elements each of a source and a target measure and
computes the Wasserstein distance between the samples.
The mean distance out of K
tries is returned.
subwasserstein(
source,
target,
S,
K = 1,
p = 1,
costM = NULL,
prob = TRUE,
precompute = FALSE,
method = "networkflow"
)
The mean of the K values of the Wasserstein distances between the subsampled measures.
The source measure has to be either a weight vector or an object
of one of the classes "pgrid"
, "wpp"
or "pp"
.
The target measure needs to be of the same type as the source measure.
The sample size.
The number of tries. Defaults to 1.
The order of the Wasserstein metric (i.e. the power of the distances). Defaults to 1.
The cost matrix between the source and target measures. Ignored unless source and target are weight vectors.
logical. Should the objects a, b be interpreted as probability measures, i.e. their total mass be normalized to 1?
logical. Should the cost matrix for the large problem be precomputed?
A string with the name of the method used for optimal transport distance computation. Options are "revsimplex", "shortsimplex" and "primaldual". Defaults to "revsimplex".
Jörn Schrieber joern.schrieber-1@mathematik.uni-goettingen.de
Dominic Schuhmacher dominic.schuhmacher@mathematik.uni-goettingen.de
For larger problems setting precompute
to TRUE
is not recommended.
M. Sommerfeld, J. Schrieber, Y. Zemel and A. Munk (2018) Optimal Transport: Fast Probabilistic Approximation with Exact Solvers preprint: arXiv:1802.05570
if (FALSE) {
subwasserstein(random64a, random64b, S=1000)
wasserstein(random64a, random64b)
}
Run the code above in your browser using DataLab