I have a list of 40 elements. I am trying to estimate how many times I need to sample this list in order to reproduce all elements in that list. However, it is important that I replace the picked element. I.e. it is possible that I will pick the same element 20 times. So far I have the following
import random
l = range(0,40)
seen=[]
x=0
while len(seen)<len(l):
r = random.choice(l)
if r not in seen:
seen.append(r)
x=x+1
print x
However, this always returns that it took 40 times to accomplish what I want. However, this is because a single element is never selected twice. Eventually I would run this function 1000 times to get a feel for how often I would have to sample. as always, thanks