RANDSUBSET
by Bruno Luong
23 Jun 2010
(Updated 29 Jun 2010)
Return a random subset of k elements of the set of n elements
|
Watch this File
|
| File Information |
| Description |
A = RANDSUBSET(N, K) is equivalent to
ALLSUBSETS = NCHOOSEK(1:N,K);
A = ALLSUBSETS(RANDI(NCHOOSEK(N,K)));
% or
A = RANDPERM(N);
A = SORT(A(1:k));
This function can also be used to generate random sampling without replacement by calling RANDPERM on the output.
It works advantageously with large N (but "reasonable" K), and fast! |
| MATLAB release |
MATLAB 7.10 (2010a)
|
| Other requirements |
Mex correctly setup |
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Updates |
| 24 Jun 2010 |
Mex engine |
| 29 Jun 2010 |
Change the description |
|
Contact us at files@mathworks.com