Python伯努利分布

伯努利分布是二项分布的特例,其中进行了单个实验,因此观察次数为1。因此,伯努利分布因此描述了具有两个结果的事件。

在numpy库中使用各种函数来数学计算伯努利分布的值。通过绘制概率分布曲线来创建直方图。

from scipy.stats import bernoulli
import seaborn as sb

data_bern = bernoulli.rvs(size=1000,p=0.6)
ax = sb.distplot(data_bern,
                  kde=True,
                  color='crimson',
                  hist_kws={"linewidth": 25,'alpha':1})
ax.set(xlabel='Bernouli', ylabel='Frequency')

执行上面示例代码,得到以下结果 –

《Python伯努利分布》

        原文作者:Python数据科学
        原文地址: https://www.yiibai.com/python_data_science/python_bernoulli_distribution.html
        本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
    点赞