ESSAY / NOTE

python中生成具有特定概率的随机数列表

0 and 1生成1000个随机数的列表。在 0 has the prob of 40% 1 has the prob of 60%
for i in range(1000):
#creates one number out of 0 or 1 with prob p 0.4 for 0 and 0.6 for 1
    test = numpy.random.choice(numpy.arange(0, 2), p=[0.4, 0.6])
    myProb.append(test)