kantorovich: Kantorovich distance

View source: R/kantorovich.R

kantorovichR Documentation

Kantorovich distance

Description

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

Usage

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

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 Aug. 23, 2023, 1:06 a.m.