Probability distribution function in Python

删除回忆录丶 提交于 2019-12-06 10:26:20

问题


I know how to create an histogram in Python, but I would like that it is the probability density distribution.

Let's start with my example. I have an array d, with a size of 500000 elements. With the following code I am building a simple histogram telling me how many elements of my array d are between every bin.

max_val=log10(max(d))
min_val=log10(min(d))

logspace = np.logspace(min_val, max_val, 50)
H=hist(select,bins=logspace,histtype='step')

The problem is that this plot is not what I want. I would like to have the probability distribution function of my array d. Instead of having the number of elements of my array which are within every bins, I would like to have the probability of them being in that bin. I tried with normed=True, but that seems not working since I have bins which are equally logspaced.


回答1:


It's not clear what your hist function is. If you're using NumPy's histogram, try setting density=True. See http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html .



来源:https://stackoverflow.com/questions/7062936/probability-distribution-function-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!