I want to plot the probability density function, but
> hist(...,normed=1,...) does not work as expected. Here is
> the code (with ipython line prompts):
> In [69]: n, bins, patches = hist(data, bins = 100, normed =
> 1) [ 0.12485649, 0.03013777, 0.03874856, 0. , 0.00861079,
> 0. , 0. , 0. , 0. , 0. , 0.0043054 , 0.0043054 , 0. ,
> 0. , 0.0043054 , 0. , 0. , 0. , 0. , 0. , 0. ,
> 0.0043054 , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ,
> 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ,
> 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ,
> 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ,
> 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ,
> 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ,
> 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ,
> 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ,
> 0.0043054 ,] In [72]: sum(n) Out[72]: 0.22388059701492535
> Should this not sum to 1.0 for it to be a PDF? Thanks
It should integrate to one
import matplotlib.mlab
matplotlib.mlab.trapz(bins, n)
JDH