kantorovich_ompr: Computes Kantorovich distance with 'ompr'

View source: R/kantorovich_ompr.R

kantorovich_omprR Documentation

Computes Kantorovich distance with 'ompr'

Description

Kantorovich distance using the ompr package

Usage

kantorovich_ompr(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 solve_model is returned with a warning

Note

The glpk solver is the one used to solve the problem.

Examples

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


stla/kantorovich documentation built on April 26, 2024, 5:19 a.m.