필터 지우기
필터 지우기

Partial not all possible k combinations out of total N in MATLAB

조회 수: 1 (최근 30일)
Mahmoud Zeydabadinezhad
Mahmoud Zeydabadinezhad 2016년 2월 22일
답변: John D'Errico 2016년 2월 22일
I have a list of 60 IDs, and I'd like to have ONLY around 10,000 of all possible 30 combinations out of the total 60 IDs. How can I do this in MATLAB? combnk() and nchoosek() won't help because the vector size is greater than 15. I appreciate any help or comment.
Thank you!

답변 (1개)

John D'Errico
John D'Errico 2016년 2월 22일
I assume you mean to generate 10000 samples of 30 elements taken from a superset of 60 elements.
What is the problem? Just sample randomly. The odds of a duplicate sample are pretty small, given the huge number of combinations possible:
nchoosek(60,30)
Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits
> In nchoosek (line 92)
ans =
1.18264581564861e+17
Regardless, if you are worried, then generate 10001 samples, then throw the result into unique, with the rows option. If no replicates, toss the extra one.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by