lundi 5 septembre 2016

Truncating a random gammavariate result to an upper limit

I want to draw a number from a gammavariate, but I want to set an upper limit. Why this does not work?

import random
[int(random.gammavariate(3, 3)) if x < 21 else 20 for x in range(1)]

Out[59]: [22]

Thanks.




Aucun commentaire:

Enregistrer un commentaire