Python has my_sample = random.sample(range(100), 10)
to randomly sample without replacement from [0, 100)
.
Suppose I have sampled n
such numbers and now I want to sample one more without replacement (without including any of the previously sampled n
), how to do so super efficiently?
update: changed from "reasonably efficiently" to "super efficiently" (but ignoring constant factors)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…