kantorovich: Kantorovich distance

Description Usage Arguments Details Value Examples

View source: R/kantorovich.R

Description

Compute the Kantorovich distance between two probability measures on a finite set.

Usage

1
kantorovich(mu, nu, dist = NULL, details = FALSE, ...)

Arguments

mu

(row margins) probability measure in numeric or bigq/character mode

nu

(column margins) probability measure in numeric or bigq/character mode

dist

function or matrix, the distance to be minimized on average; if NULL, the 0-1 distance is used.

details

prints the joinings achieving the Kantorovich distance and returns them in the "joinings" attribute of the output

...

arguments passed to dist (only if it is a function)

Details

The function firstly computes all the extreme joinings of mu and nu, then evaluates the average distance for each of them, and then returns the minimal one.

Value

The Kantorovich distance between mu and nu.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
mu <- c(1/7, 2/7, 4/7)
nu <- c(1/4, 1/4, 1/2)
kantorovich(mu, nu)
library(gmp)
mu <- as.bigq(c(1,2,4), 7)
nu <- as.bigq(c(1,1,1), c(4,4,2))
kantorovich(mu, nu)
mu <- c("1/7", "2/7", "4/7")
nu <- c("1/4", "1/4", "1/2")
kantorovich(mu, nu, details=TRUE)

kantorovich documentation built on Oct. 29, 2020, 1:06 a.m.