[Numpy-discussion] histogram2d and histogramdd return counts as floats while histogram returns ints

Nils Becker n.becker at amolf.nl
Mon May 14 04:13:03 EDT 2012


> is this intended?
> 
> np.histogramdd([[1,2],[3,4]],bins=2)
> 
> (array([[ 1.,  0.],
>        [ 0.,  1.]]),
>  [array([ 1. ,  1.5,  2. ]), array([ 3. ,  3.5,  4. ])])
> 
> np.histogram2d([1,2],[3,4],bins=2)
> 
> (array([[ 1.,  0.],
>        [ 0.,  1.]]),
>  array([ 1. ,  1.5,  2. ]),
>  array([ 3. ,  3.5,  4. ]))
> 
> np.histogram([1,2],bins=2)
> 
> (array([1, 1]), array([ 1. ,  1.5,  2. ]))

maybe i should have been more explicit. what i meant to say is that

1. the counts in a histogram are integers. whenever no normalization is
used i would expect that i get an integer array when i call a histogram
function.
2. now it might be intended that the data type is always the same so
that float has to be used to accomodate the normalized histograms.
3. in any case, the 1d histogram function handles this differently from
the 2d and dd ones. this seems inconsistent and might be considered a bug.

n.




More information about the NumPy-Discussion mailing list