ws_dist: Compute the p-Wasserstein distance between two measures

Description Usage Arguments Value References Examples

View source: R/ws_dist.R

Description

This is essentially a wrapper function of transport. It has the advantage of allowing more general input objects, such as images or matrices, without the user having to manually convert these objects.

Usage

1
ws_dist(A, B, p = 2, sampling = FALSE, S = NULL, R = NULL)

Arguments

A

One of the following: A matrix, representing an image; A file name containing an image; A wpp-object.

B

One of the following: A matrix, representing an image; A file name containing an image; A wpp-object.

p

A positive real number specifying the power of the Wasserstein distance.

sampling

A boolean specifying whether a stochastic approximation (Sommerfeld et al., 2019) should be used to approximate the distance.

S

A positive integer specifying the number of samples drawn in the stochastic approximation.

R

The number of repetitions averaged over in the stochastic approximation.

Value

A number specifying the computed p-Wasserstein distance.

References

M Sommerfeld, J Schrieber, Y Zemel, and A Munk (2019). Optimal transport: Fast probabilistic approximations with exact solvers. Journal of Machine Learning Research 20(105):1–23.

Examples

1
2
3
4
5
P1<-transport::random32a$mass
P2<-transport::random32b$mass
P1<-P1/sum(P1)
P2<-P2/sum(P2)
ws_dist(P1,P2)

WSGeometry documentation built on Dec. 15, 2021, 1:08 a.m.