Python matplotlib 概率论与数理统计 伯努利分布 二项分布

版权声明:版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/DarrenXf/article/details/82914578

Python 代码实现 二项分布

import numpy as np
import matplotlib.pyplot as plt 
import math
from scipy import stats

n = 100 
p = 0.05
k = np.arange(0,n)
binomial = stats.binom.pmf(k,n,p)
plt.plot(k,binomial,'o-')
plt.title('binomial:n=%i,p=%.2f'%(n,p),fontsize=15)
plt.xlabel('number of sucess',fontproperties='SimHei')
plt.ylabel('probalility of sucess',fontsize=15)
plt.grid(True)
plt.show()

猜你喜欢

转载自blog.csdn.net/DarrenXf/article/details/82914578