RANDSUBSET

Return a random subset of k elements of the set of n elements
401 download
Aggiornato 29 giu 2010

Visualizza la licenza

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!

Cita come

Bruno Luong (2025). RANDSUBSET (https://it.mathworks.com/matlabcentral/fileexchange/28002-randsubset), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2010a
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su Random Number Generation in Help Center e MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release
1.2.0.0

Change the description

1.1.0.0

Mex engine

1.0.0.0