kantorovich_glpk: Computes Kantorovich distance with GLPK

View source: R/kantorovich_glpk.R

kantorovich_glpkR Documentation

Computes Kantorovich distance with GLPK

Description

Kantorovich distance using the Rglpk package

Usage

kantorovich_glpk(mu, nu, dist, solution = FALSE, stop_if_fail = TRUE, ...)

Arguments

mu

(row margins) probability measure in numeric mode

nu

(column margins) probability measure in numeric mode

dist

matrix defining the distance to be minimized on average

solution

logical; if TRUE the solution is returned in the "solution" attributes of the output

stop_if_fail

logical; if TRUE, an error is returned in the case when no solution is found; if FALSE, the output of Rglpk_solve_LP is returned with a warning

...

arguments passed to Rglpk_solve_LP

Examples

x <- c(1.5, 2, -3)
mu <- c(1/7, 2/7, 4/7)
y <- c(4, 3.5, 0, -2)
nu <- c(1/4, 1/4, 1/4, 1/4)
M <- outer(x, y, FUN = function(x, y) abs(x - y))
kantorovich_glpk(mu, nu, dist = M)


stla/kantorovich documentation built on March 30, 2024, 1:08 p.m.