wasserstein {transport}R Documentation

Compute the Wasserstein Distance Between Two Objects

Description

Given two objects a and b that specify measures in R^d, compute the Wasserstein distance of order p between the objects.

Usage

wasserstein(a, b, p=1, tplan=NULL, costm=NULL, prob=TRUE, ...)

Arguments

a, b

two objects that describe mass distributions in R^d. Either both of class pgrid or pp or wpp or numeric. For the first three the dimension d of the structures must be at least 2; see function wasserstein1d for d=1.

p

the power \geq 1 to which the Euclidean distance between points is taken in order to compute transportation costs.

tplan

an optional transference plan in the format returned by the function transport. If NULL an optimal transference plan based on a, b and p is computed by a call to transport.

costm

the matrix of costs between the support points of the measures. Ignored unless a and b are numeric vectors.

prob

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

...

further parameters passed to transport if tplan is NULL.

Details

The Wasserstein distance of order p is defined as the p-th root of the total cost incurred when transporting measure a to measure b in an optimal way, where the cost of transporting a unit of mass from x to y is given as the p-th power \|x-y\|^p of the Euclidean distance.

If tplan is supplied by the user, no checks are performed whether it is optimal for the given problem. So this function may be used to compare different (maybe suboptimal) transference plans with regard to their total costs.

For further details on the algorithms used, see help of transport.

Value

A single number, the Wasserstein distance for the specified problem.

Author(s)

Dominic Schuhmacher dschuhm1@uni-goettingen.de

See Also

plot, transport, wasserstein1d

Examples

#
# example for class 'pgrid'
#
wasserstein(random32a,random32b,p=1)
res <- transport(random32a,random32b,p=2)
wasserstein(random32a,random32b,p=1,res)
# is larger than above:
# the optimal transport for p=2 is not optimal for p=1

#
# example for class 'pp'
#
set.seed(27)
x <- pp(matrix(runif(500),250,2))
y <- pp(matrix(runif(500),250,2))
wasserstein(x,y,p=1)
wasserstein(x,y,p=2)

[Package transport version 0.15-2 Index]