Implements the Sinkhorn--Knopp algorithm for transforming a square matrix with positive entries to a stochastic matrix with given common row and column sums (e.g., a doubly stochastic matrix).
sinkhorn_knopp(
A,
sums = rep(1, nrow(A)),
niter = 100,
tol = 1e-08,
sym = FALSE,
verb = FALSE
)
Diagonal matrices D1 and D2 to make D1AD2 into a matrix with given row/column sums.
input matrix
desired row/column sums
number of iterations
convergence tolerance
whether to compute symmetric scaling D A D
whether to print the current change
Computes diagonal matrices D1 and D2 to make D1AD2 into a matrix with
given row/column sums. For a symmetric matrix A
, one can set sym = TRUE
to
compute a symmetric scaling DAD.