wasserstein {dad}R Documentation

2-Wasserstein distance between Gaussian densities

Description

The 2-Wasserstein distance between two multivariate (p > 1) or univariate (p = 1) Gaussian densities (see Details).

Usage

wasserstein(x1, x2, check = FALSE)

Arguments

x1

a matrix or data frame of n_1 rows (observations) and p columns (variables) (can also be a tibble) or a vector of length n_1.

x2

matrix or data frame (or tibble) of n_2 rows and p columns or vector of length n_2.

check

logical. When TRUE (the default is FALSE) the function checks if the covariance matrices are not degenerate (multivariate case) or if the variances are not zero (univariate case).

Details

The Wasserstein distance between the two Gaussian densities is computed by using the wassersteinpar function and the density parameters estimated from samples.

Value

Returns the 2-Wasserstein distance between the two probability densities.

Be careful! If check = FALSE and one smoothing bandwidth matrix is degenerate, the result returned can not be considered.

Author(s)

Rachid Boumaza, Pierre Santagostini, Smail Yousfi, Gilles Hunault, Sabine Demotes-Mainard

References

Peterson, A., Mueller, H.G. (2016). Functional Data Analysis for Density Functions by Transformation to a Hilbert Space. The annals of Statistics, 44 (1), 183-218. DOI: 10.1214/15-AOS1363

Dowson, D.C., Ladau, B.V. (1982). The Fréchet Distance between Multivariate Normal Distributions. Journal of Multivariate Analysis, 12, 450-455.

See Also

wassersteinpar: 2-Wasserstein distance between Gaussian densities, given their parameters.

Examples

require(MASS)
m1 <- c(0,0)
v1 <- matrix(c(1,0,0,1),ncol = 2) 
m2 <- c(0,1)
v2 <- matrix(c(4,1,1,9),ncol = 2)
x1 <- mvrnorm(n = 3,mu = m1,Sigma = v1)
x2 <- mvrnorm(n = 5, mu = m2, Sigma = v2)
wasserstein(x1, x2)

[Package dad version 4.1.2 Index]