How to incrementally sample without replacement?

前端 未结 13 1611
别跟我提以往
别跟我提以往 2020-12-05 00:38

Python has my_sample = random.sample(range(100), 10) to randomly sample without replacement from [0, 100).

Suppose I have sampled n

13条回答
  •  爱一瞬间的悲伤
    2020-12-05 01:24

    Reasonably fast one-liner (O(n + m), n=range,m=old samplesize):

    next_sample = random.sample(set(range(100)).difference(my_sample), 10)
    

提交回复
热议问题