I was wondering how I could generate a list of random number (1, 2) but with different probability. ie : 1 has a probability of 0.6 and 2 has a probability of 0.4.
Thanks!
I was wondering how I could generate a list of random number (1, 2) but with different probability. ie : 1 has a probability of 0.6 and 2 has a probability of 0.4.
Thanks!
Use random.choice
import random
random.choice([1,1,1,1,1,1,2,2,2,2])
You can also write
data = [1]*6 + [2]*4
choice = random.choice(data)