# A Fast Scheme for the Uniform Sampling of Binary Matrices with Fixed Margins

Uniform sampling of binary matrix with fixed margins is an important and difficult problem in statistics, computer science, ecology and so on. The well-known swap algorithm would be inefficient when the size of the matrix becomes large or when the matrix is too sparse/full. Here we propose the Rectangle loop algorithm, a Markov-chain Monte Carlo algorithm to sample binary matrices with fixed margins uniformly. Theoretically the Rectangle loop algorithm is better than the swap algorithm in Peskun's order. Empirically studies also demonstrates the Rectangle loop algorithm is remarkablely more efficient than the swap algorithm.

READ FULL TEXT