编程语言
首页 > 编程语言> > Python 模拟伯努利试验

Python 模拟伯努利试验

作者:互联网

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

代码:

from scipy import stats
import numpy as np

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

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

# 查看结果
trails

 

 

标签:27,stats,Python,trails,bernoulliDist,import,模拟,伯努利
来源: https://www.cnblogs.com/shanger/p/11963396.html