绘制Poisson分布

练习:Poisson分布

绘制Poisson分布_第1张图片
#coding:utf-8
#/usr/bin/python
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt


if __name__ == '__main__':
    mpl.rcParams['font.sans-serif'] = [u'SimHei']
    mpl.rcParams['axes.unicode_minus'] = False  # win正常显示中文设置
    
    x = np.random.poisson(lam=5, size=10000)
    print(x)
    pillar = 15
    a = plt.hist(x, bins=pillar, normed=True, range=[0, pillar], color='g', alpha=0.5)
    plt.grid()
    plt.show()
    print(a)
    print(a[0].sum())

你可能感兴趣的:(绘制Poisson分布)