fastball {backbone} | R Documentation |

## Randomize a binary matrix using the fastball algorithm

### Description

`fastball`

randomizes a binary matrix, preserving the row and column sums

### Usage

```
fastball(M, trades = 5 * nrow(M))
```

### Arguments

`M` |
matrix: a binary matrix (see details) |

`trades` |
integer: number of trades; the default is 5R trades (approx. mixing time) |

### Details

Given a matrix `M`

, `fastball`

randomly samples a new matrix from the space of all matrices with the same row and column sums as `M`

.

### Value

matrix: A random binary matrix with same row sums and column sums as M.

### References

fastball: Godard, Karl and Neal, Zachary P. 2022. fastball: A fast algorithm to sample bipartite graphs with fixed degree sequences. *Journal of Complex Networks* doi:10.1093/comnet/cnac049

### Examples

```
M <- matrix(rbinom(200,1,0.5),10,20) #A random 10x20 binary matrix
Mrand <- fastball(M) #Random matrix with same row and column sums
```

[Package

*backbone*version 2.1.4 Index]