Code covered by the BSD License
-
nchoosek_m(n, k, m)
nchoosek_m: efficiently compute the mth combination of nchoosek(1:n, k)
-
perms_m(n, m)
perms_m(n, m): return the mth permutation of the digits 1:n
-
sample_no_repl(n, k)
sample_no_repl(n, k): k random samples from 1:n, without replacement.
-
signs_m(n, m)
-
uperms(X, k)
uperms: unique permutations of an input vector or rows of an input matrix
-
View all files
Unique random permutations
by Ged Ridgway
21 Apr 2010
Random sample (without replacement) from unique permutations of a vector or row-perms of a matrix
|
Watch this File
|
| File Information |
| Description |
1. Determines number of available unique permutations.
2. Computes a random set of unique permutations, containing the identity permutation.
MATLAB's "perms" is unsuitable for vectors longer than about 11 elements (where the output takes over 3GB). John D'Errico's "uniqueperms" is much better if there are relatively few unique permutations, but is not well suited to randomly sampling a small subset of a large number of unique permutations. On the other hand, repeated calls to randperm can produce duplicates.
"uperms" aims to fill the niche between these, and is ideal for use with statistical permutation testing algorithms (where it is helpful to know if the identity is or isn't present, hence the choice to guarantee it here; just ask for k+1 and use 2:end if you don't want the identity).
Some other routines are also included to provide faster solutions in special cases of permutation test: simple correlation (perms_m); one-sample t-test (signs_m); and two-sample t-test (nchoosek_m). See also:
http://www.fmrib.ox.ac.uk/fsl/randomise/index.html#theory
|
| Acknowledgements |
This file inspired
Nsumk.
|
| MATLAB release |
MATLAB 7.1.0 (R14SP3)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
|
Contact us