Learn R Programming

transport (version 0.15-4)

subwasserstein: Approximate Computation of Wasserstein Distances via Subsampling.

Description

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.

Usage

subwasserstein(
  source,
  target,
  S,
  K = 1,
  p = 1,
  costM = NULL,
  prob = TRUE,
  precompute = FALSE,
  method = "networkflow"
)

Value

The mean of the K values of the Wasserstein distances between the subsampled measures.

Arguments

source

The source measure has to be either a weight vector or an object of one of the classes "pgrid", "wpp" or "pp".

target

The target measure needs to be of the same type as the source measure.

S

The sample size.

K

The number of tries. Defaults to 1.

p

The order of the Wasserstein metric (i.e. the power of the distances). Defaults to 1.

costM

The cost matrix between the source and target measures. Ignored unless source and target are weight vectors.

prob

logical. Should the objects a, b be interpreted as probability measures, i.e. their total mass be normalized to 1?

precompute

logical. Should the cost matrix for the large problem be precomputed?

method

A string with the name of the method used for optimal transport distance computation. Options are "revsimplex", "shortsimplex" and "primaldual". Defaults to "revsimplex".

Details

For larger problems setting precompute to TRUE is not recommended.

References

M. Sommerfeld, J. Schrieber, Y. Zemel and A. Munk (2018) Optimal Transport: Fast Probabilistic Approximation with Exact Solvers preprint: arXiv:1802.05570

Examples

Run this code
if (FALSE) {
subwasserstein(random64a, random64b, S=1000)
wasserstein(random64a, random64b)
}

Run the code above in your browser using DataLab