wasserstein {approxOT}R Documentation

Calculate the Wasserstein distance

Description

Calculate the Wasserstein distance

Usage

wasserstein(
  X = NULL,
  Y = NULL,
  a = NULL,
  b = NULL,
  cost = NULL,
  tplan = NULL,
  p = 2,
  ground_p = 2,
  method = transport_options(),
  cost_a = NULL,
  cost_b = NULL,
  ...
)

Arguments

X

The covariate data of the first sample.

Y

The covariate data of the second sample.

a

Optional. Empirical measure of the first sample

b

Optional. Empirical measure of the second sample

cost

Specify the cost matrix in advance.

tplan

Give a transportation plan with slots "from", "to", and "mass", like that returned by the [tranportation_plan()] function.

p

The power of the Wasserstein distance

ground_p

The power of the Lp norm

method

Which transportation method to use. See [transport_options()]

cost_a

The cost matrix for the first sample with itself. Only used for unbiased Sinkhorn

cost_b

The cost matrix for the second sample with itself. Only used for unbiased Sinkhorn

...

Additional arguments for various methods:

  • "niter": The number of iterations to use for the entropically penalized optimal transport distances

  • "epsilon": The multiple of the median cost to use as a penalty in the entropically penalized optimal transport distances

  • "unbiased": If using Sinkhorn distances, should the distance be de-biased? (TRUE/FALSE)

  • "nboot": If using sliced Wasserstein distances, specify the number of Monte Carlo samples

Value

The p-Wasserstein distance, a numeric value

Examples

set.seed(11289374)
n <- 100
z <- stats::rnorm(n)
w <- stats::rnorm(n)
uni <- approxOT::wasserstein(X = z, Y = w, 
p = 2, ground_p = 2, 
observation.orientation = "colwise", 
method = "univariate")

[Package approxOT version 1.1.1 Index]