伯努利分布

 

#coding:utf-8
from scipy.stats import binom  
import matplotlib.pyplot as plt  
import numpy as np  

#样本数目
n = 200
#发生的概率
p = 0.01
#发生的次数
k = np.arange(0,15)
binomial = binom.pmf(k, n, p)  
  
plt.plot(k, binomial, 'o-')  
plt.title('Binomial: n = %i, p=%0.3f' % (n, p),fontsize = 15)
plt.xlabel('Number of hit')
plt.ylabel('Probability of hit', fontsize = 15)
plt.show()  

 

posted @ 2018-03-14 18:54  similarface  阅读(684)  评论(0编辑  收藏  举报