In Matlab, from the integers 1,...,N I would like to take k distinct combinations without repetition of size p. For example, if N=10, k=4 and p=3, a possible outcome would be:
1 4 9
9 4 2
3 5 2
1 8 4
But not:
1 4 9
9 4 2
3 5 3
1 9 4
For two reasons:
-
[1 4 9]and[1 9 4]are the same combination. -
[3 5 3]is not without repetition.
Note that getting all possible combinations and the (randomly) picking k of them easily runs into memory problems.
Aucun commentaire:
Enregistrer un commentaire