python生成特定分布数的实例

yipeiwu_com5年前Python基础

我就废话不多说了,直接上代码吧!

from scipy.stats import binom, norm, beta, expon
import numpy as np
import matplotlib.pyplot as plt
#泊松分布
x = np.random.poisson(lam=34.7, size=10000) 
pillar = 100
a = plt.hist(x, bins=pillar, color='black', alpha=0.5)
plt.xlabel((u'频数'))
plt.ylabel(u'频数出现数目')
plt.grid()
plt.show()
#负二项分布
from scipy.stats import nbinom
help(nbinom)
p=0.055
r=2.1734
x = nbinom.rvs(r, p, size=10000)
pillar = 50
a = plt.hist(x, bins=pillar)
plt.xlabel((u'频数'))
plt.ylabel(u'频数出现数目')
plt.grid()
plt.show()

以上这篇python生成特定分布数的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

六个窍门助你提高Python运行效率

不喜欢Python的人经常会吐嘈Python运行太慢。但是,事实并非如此。尝试以下六个窍门,来为你的Python应用提速。 窍门一:关键代码使用外部功能包 Python简化了许多编程任务...

python: 判断tuple、list、dict是否为空的方法

Test tuple_test = () assert not tuple_test list_test = [] assert not list_test dict_test...

python扫描proxy并获取可用代理ip的实例

今天咱写一个挺实用的工具,就是扫描并获取可用的proxy 首先呢,我先百度找了一个网站:http://www.xicidaili.com 作为例子 这个网站里公布了许多的国内外可用的代理...

完美解决python遍历删除字典里值为空的元素报错问题

exam = { 'math': '95', 'eng': '96', 'chn': '90', 'phy': '', 'chem': '' } 使用下列遍历的方法删除: 1. for...

Django上线部署之IIS的配置方法

环境: 1 .Windows Server 2016 Datacenter 64位 2 .SQL Server 2016 Enterprise 64位 3 .Python 3.6.0 6...