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.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.0043054 ,]
In [72]: sum(n)
Out[72]: 0.22388059701492535
Should this not sum to 1.0 for it to be a PDF?
Thanks
The data used
is:
Out[66]:
[3.3333333333333335,
3.3333333333333335,
3.3333333333333335,
3.3333333333333335,
3.3333333333333335,
3.3333333333333335,
3.3333333333333335,
3.3333333333333335,
3.3333333333333335,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
5.5555555555555554,
6.666666666666667,
6.666666666666667,
11.111111111111111,
11.111111111111111,
11.111111111111111,
11.111111111111111,
11.111111111
111111,
11.111111111111111,
11.111111111111111,
12.5,
12.5,
12.5,
12.5,
16.666666666666664,
16.666666666666664,
16.666666666666664,
16.666666666666664,
16.666666666666664,
22.222222222222221,
22.222222222222221,
50.0,
56.666666666666664,
66.666666666666657,
100.0,
450.0]