I have an list ordered by some quality function from which I'd like to take elements, preferring the good elements at the beginning of the list.
Currently, my function to generate the random indices looks essentially as follows:
def pick():
p = 0.2
for i in itertools.count():
if random.random() < p:
break
return i
It does a good job, but I wonder:
- What's the name of the generated random distribution?
- Is there a built-in function in Python for that distribution?
Aucun commentaire:
Enregistrer un commentaire