Python 模拟伯努利试验

模拟 27 次投掷硬币的伯努利试验

代码:

from scipy import stats
import numpy as np

p = 0.5
# 生成冻结分布函数
bernoulliDist = stats.bernoulli(p) 

# 模拟 27 次伯努利实验
trails = bernoulliDist.rvs(27) 

# 查看结果
trails

猜你喜欢

转载自www.cnblogs.com/shanger/p/11963396.html