-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c52c7e
commit 38e172d
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# RandomBooleanMatrices | ||
Create random boolean matrices that maintain row and column sums. This is a very common use case for null models in ecology. | ||
The package offers the newest and most efficient unbiased algorithms for generating random matrices. Legacy approaches have | ||
used different forms of swapping, or some alternative approaches like the `quasiswap` algorithm in R's vegan package. These | ||
methods are neither efficient, nor are they guaranteed to sample the possible distribution of boolean vectors with a given row | ||
and column sum equally. | ||
|
||
Currently, the package only offers an implementation of the `curveball` algorithm of Strona et al. (2014). There are two forms: | ||
a `randomize_matrix!` function that will randomize a sparse boolean `Matrix` in-place, and a generator form: | ||
|
||
```julia | ||
using SparseArrays, RandomBooleanMatrices | ||
|
||
# in-place | ||
m = sprand(Bool, 1000, 1000, 0.1) | ||
randomize_matrix!(m) | ||
|
||
# genenrator | ||
m = sprand(Bool, 1000, 1000, 0.1) | ||
rmg = random_matrices(m) | ||
m1 = rmg() # creates a new random matrix | ||
m2 = rmg() | ||
``` | ||
|
||
### References | ||
Strona, G., Nappo, D., Boccacci, F., Fattorini, S. & San-Miguel-Ayanz, J. (2014) | ||
A fast and unbiased procedure to randomize ecological binary matrices with fixed row and column totals. | ||
Nature Communications, 5, 4114. |