Tag Info

New answers tagged

0

I interpret the original question to mean that no element of any subset can appear in any other subset (much like RandomKSubsets). Here's an inelegant but workable approach. Basically, select numElements from myList and remove them from myList, and repeat numSets times. That way, you will never get any duplicates, i.e., elements that appear in two or more ...


3

Combinatorica has a function for doing exactly this: << "Combinatorica`" RandomKSubset[Range@300, 25] & /@ Range@5 // Grid You may get dups, though. Use DeleteDuplicates[] if you consider it necessary.


3

Another approach: Generate a bunch of random samples, cull any duplicates, then take as many as you need. (DeleteDuplicates@Table[ Sort@RandomSample[list, 25] , {2000}] )[[;; 1000]] a variant.. RandomSample[ Union@Table[ Sort@RandomSample[list, 25] , {2000}] , 1000 ] basically the same but there may be some performance difference.


8

I think RandomSample already does exactly what you need: RandomSample: RandomSample[Range[300], 25] (* {292, 257, 36, 83, 259, 245, 280, 270, 24, 236, 186, 100, 300, 240, 176, 295, 42, 105, 97, 106, 60, 114, 63, 25, 253} *) Table[RandomSample[Range[300], 25], {5}] {{221, 54, 124, 64, 168, 91, 149, 25, 142, 87, 184, 288, 93, 105, 95, 195, 264, 180, ...


9

This question may be a duplicate but for the time being: list = Range[300]; The number of subsets length 25: n = Binomial[300, 25] 1953265141442868389822364184842211512 Five samples: samp = RandomInteger[{1, n}, 5] {1097179597483122074395819626389736050, 1278400886908268917844987164926797363, 1855898035549513136165016617586671669, ...



Top 50 recent answers are included