Open
Description
When no normalization is performed the histogram*d
functions should return an int
array, just as histogram
does. A float
array is returned instead.
The docs of histogram2d
don't mention anything about return type, but also don't follow the style of the docs of histogram
, in which it is stated that semantics depend on normalization (I guess this could be written more explicitly). histogramdd
does follow the doc style of histogram
, but also returns a float
array, like histogram2d
does.
Running NumPy 1.11.0 on Ubuntu 14.04
Sample code:
arr = np.random.random((20))
## 1D
np.histogram(arr)[0]
Out: array([5, 1, 1, 1, 2, 1, 2, 1, 2, 4])
## 2D
np.histogram2d(arr,arr)[0]
Out:
array([[ 5., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 2., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 2., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 1., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 2., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 4.]])
## N-D
np.histogramdd(arr[:,None])[0]
Out: array([ 5., 1., 1., 1., 2., 1., 2., 1., 2., 4.])
#
np.histogramdd(np.column_stack((arr, arr)))[0]
Out:
array([[ 5., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 2., 0., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 2., 0., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 1., 0., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 2., 0.],
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 4.]])