例如,
尝试仅使用 .生成一个包含 1000 个随机数的列表0 and 1。
英石
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)
Run Code Online (Sandbox Code Playgroud)
打印(我的问题)