开发者

How to draw probabilistic distributions with numpy/matplotlib?

开发者 https://www.devze.com 2023-02-18 13:14 出处:网络
I want to draw probabilistic functions (like the binomial distribution), but i don\'t find a function that returns the probability for given parameters. To write it myself i need binomial coefficients

I want to draw probabilistic functions (like the binomial distribution), but i don't find a function that returns the probability for given parameters. To write it myself i need binomial coefficients (I could write that myself), for which I haven't found a function either. Is there a 'short and/or easy' to do this?

To clarify: I don't want to draw histograms, and I 开发者_运维问答dont want to fit a line to one.


scipy.stats.binom.pmf gives the probability mass function for the binomial distribution. You could compute it for a range and plot it. for example, for 10 trials, and p = 0.1, you could do

import scipy, scipy.stats
x = scipy.linspace(0,10,11)
pmf = scipy.stats.binom.pmf(x,10,0.1)
import pylab
pylab.plot(x,pmf)
0

精彩评论

暂无评论...
验证码 换一张
取 消