Python数据处理
Python数据可视化
Python统计分析

Python伯努利分布

Python伯努利分布详细操作教程
伯努利分布是二项分布的特例,其中进行了单个实验,因此观察次数为1。因此,伯努利分布因此描述了具有两个结果的事件。
在numpy库中使用各种函数来数学计算伯努利分布的值。通过绘制概率分布曲线来创建直方图。
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-23
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')
执行上面示例代码,得到以下结果 -
伯努利分布
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4