mercredi 16 octobre 2019

random.choices() in python

I'd like to confirm that

a = [random.choices([0,1],weights=[0.2,0.8],k=1) for i in range(0,10)] 

does probabilistically the same thing as

a = random.choices([0,1],weights=[0.2,0.8],k=10) 

In particular, I expect both to make 10 independent draws from the set {0,1} with probability 0.2 on 0 and 0.8 on 1. Is this right?

Thanks!




Aucun commentaire:

Enregistrer un commentaire