Sinkhorn {Barycenter}R Documentation

Sinkhorn Distances (upper bound to EMD)


The Sinkhorn algorithm to compute N dual-Sinkhorn divergences, i.e. upper bounds on the earth movers distance (EMD), a.k.a. Wasserstein distance.


Sinkhorn(a, b, costm, lambda = 1, maxIter = 10000, tolerance=10^(-8))



Either a d_1 x 1 column vector in the probability simplex (nonnegative summing to one) or a d_1 x N matrix, where each column is in the probability simplex.


A d_1 x N matrix of N vectors in the probability simplex.


A matrix of pairwise distances/costs between bins described in a and bins in the b_1,...,b_N histograms.


Non-negative regularization parameter (for small lambda the Sinkhorn Distance is close to the EMD).


Maximum number of iterations.


A threshold for the integrated stopping criterion based on marginal differences.


Returns the Sinkhorn Distances between the given bins. If a is given by a d_1 x 1 column vector the function returns the distances


If a is given by a d_1 x N matrix the function returns the distances


If a and b are simply given by two d_1 x 1 and d_2 x 1 vectors each in the probability simplex, respectively, then the functions returns a list containing the Sinkhorn Distance as well as the corresponding regularized transport plan.


Marcel Klatt


Cuturi, M.: Sinkhorn Distances: Lightspeed Computation of Optimal Transport, Advances in Neural Information Processing Systems 26, 2013


#Sinkhorn Distances between the first image to the remaining four images in the dataset eight.
#We creat costm simply using a distance matrix on the grid [0,1]x[0,1].
n <- seq(0,1,length.out = dim(eight[[1]])[2])
costm <- as.matrix(dist(expand.grid(n,rev(n)), diag=TRUE, upper=TRUE))
a <- matrix(eight[[1]],28*28,1)
b <- matrix(c(eight[[2]],eight[[3]],eight[[4]],eight[[5]]),28*28,4)
Sinkhorn(a, b, costm)

[Package Barycenter version 1.3.1 Index]