View source: R/kantorovich_ompr.R
kantorovich_ompr | R Documentation |
Kantorovich distance using the ompr
package
kantorovich_ompr(mu, nu, dist, solution = FALSE, stop_if_fail = TRUE)
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 |
stop_if_fail |
logical; if |
The glpk
solver is the one used to solve the problem.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.