Probability Mass Function of a Binomial Distribution in Python

不羁岁月 提交于 2019-12-01 08:40:44

Just call binom.pmf(1, n, p) to get your result for k=1. The expression in the documentation is just showing you how the PMF is mathematically defined and is not an actual code snippet that you are expected to execute.

You can use scipy.stats.binom.pmf(k) for this. For example:

n = 10
p = 0.3
k = np.arange(0,21)
binomial = scipy.stats.binom.pmf(k,n,p)
print(binomial)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!