Probability distribution function in Python
I know how to create an histogram in Python, but I would like that it is the probability density distribution.
Le开发者_开发知识库t'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.
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 .
精彩评论