Skip to contents

Alternate row and column normalisation until the row sums deviate from 1 by less than tol (Sinkhorn 1964); converges for matrices with total support (every nonzero entry on a positive diagonal).

Usage

SinkhornWeights(W, tol = 1e-12, maxit = 10000L)

Arguments

W

Non-negative square matrix.

tol

Tolerance.

maxit

Maximum sweeps.

Value

List with W, iterations, deviation.

References

Sinkhorn, R. (1964). A relationship between arbitrary positive matrices and doubly stochastic matrices. The Annals of Mathematical Statistics 35, 876-879.

Examples

SinkhornWeights(rbind(c(0, 1, 1), c(1, 0, 1), c(1, 1, 0)))$W
#>      [,1] [,2] [,3]
#> [1,]  0.0  0.5  0.5
#> [2,]  0.5  0.0  0.5
#> [3,]  0.5  0.5  0.0