# Randomsample without repetition [closed]

I'm looking for a simple way to generate random samples of lists of integers such that each time I sample I'm sure it chooses a new random sample. This is closely related to Picking random items out of a list only once except that I cannot just generate all lists of samples because it is way too large.

EDIT

For example I would like to find a (1 is enough) sample of 40 elements from a set of 100 that have a certain property. Generating all random samples is impossible and while we could generate them one by one I ould prefer to take random samples.

• I don't follow. Can you show an example? Nov 13 '20 at 11:31
• Use RandomChoice once and break into subsets? Nov 13 '20 at 16:49
• What do you mean by "random sample"? Do you mean a random permutation of elements? Nov 14 '20 at 12:48
• It sounds like you just want RandomSample[list, 40] . There will be no repetition in the result. Please read the documentation because it sounds like you don't know about the second argument. Nov 14 '20 at 12:51

It seems to me the key to this question is "such that each time I sample I'm sure it chooses a new random sample": RandomSample[] would in principle possibly generate repetitions.
Now, for your example of 100 numbers and samples of size 40, it's easy to see that if you just use RandomSample[] the probability of ever seeing a repeated sample is minuscule: consider you have Binomial[100, 40] ~ 10^28 possible choices, so even if you eventually see 10^10 samples you'd have Binomial[10^10, 2] ~ 10^19 pairs to test, thus you expect to have ~10^-9 collisions! So if this is your actual situation just use RandomSample[], because trying to remember which samples you've seen will be useless and might in the worst case lead you to memory issues.
• I think people are confused whether you mean two samples (= two results of RandomSample[..]) should be distinct samples or that in a single sample there should be no repetitions. I think you mean the former. And to clarify {1, 2} and {1, 3} are distinct samples, no? Nov 14 '20 at 20:21