K <- 3
N <- 2
costm <- cost_matrix_lp(1:N)
w <- rep(1 / K, K)
# all measures are equal
mu <- matrix(1 / N, K, N, TRUE)
# to run this, a LP solver must be available for ROI (ROI.plugin.glpk by default)
if (requireNamespace("ROI.plugin.glpk")) {
solver <- ot_test_lp_solver("glpk")
print(ot_barycenter(mu, costm, w = w, solver = solver))
}
# not all measures are equal
mu[2, ] <- 1:N / sum(1:N)
if (requireNamespace("ROI.plugin.glpk")) {
solver <- ot_test_lp_solver("glpk")
print(ot_barycenter(mu, costm, w = w, solver = solver))
}
Run the code above in your browser using DataLab