dist4den {frechet}R Documentation

L^2 Wasserstein distance between two distributions.

Description

L^2 Wasserstein distance between two distributions.

Usage

dist4den(d1 = NULL, d2 = NULL, fctn_type = NULL, optns = list())

Arguments

d1, d2

Lists holding the density functions or quantile functions of the two distributions. Each list consists of two numeric vectors x and y of the same length, where x holds the support grid and y holds the values of the function. Note that the type of functions representing the distributions in d1 and d2 should be the same—either both are density functions, or both are quantile functions. If both are quantile functions, all elements in d1$x and d2$x must be between 0 and 1. d1$x and d2$x may have different lengths.

fctn_type

Character vector of length 1 holding the function type in d1 and d2 representing the distributions: "density" (default), "quantile".

optns

A list of control parameters specified by list(name=value).

Details

Available control options are:

nqSup

A scalar giving the length of the support grid of quantile functions based on which the L^2 Wasserstein distance (i.e., the L^2 distance between the quantile functions) is computed. Default is 201.

Value

A scalar holding the L^2 Wasserstein distance between d1 and d2.

Examples

d1 <- list(x = seq(-6,6,0.01))
d1$y <- dnorm(d1$x)
d2 <- list(x = d1$x + 1)
d2$y <- dnorm(d2$x, mean = 1)
dist <- dist4den(d1 = d1,d2 = d2)

[Package frechet version 0.3.0 Index]