[Numpy-discussion] Histogram bin definition

Stéfan van der Walt stefan@sun.ac...
Wed Jul 16 08:38:21 CDT 2008

Hi all,

I am busy documenting `histogram`, and the definition of a "bin"
eludes me.  Here is the behaviour that troubles me:

>>> np.histogram([1,2,1], bins=[0, 1, 2, 3], new=True)
(array([0, 2, 1]), array([0, 1, 2, 3]))

>From this result, it seems as if a bin is defined as the half-open
interval [right_edge, left_edge).

Now, looks what happens in the following case:

>>> np.histogram([1,2,3], bins=[0,1,2,3], new=True)
(array([0, 1, 2]), array([0, 1, 2, 3]))

Here, the last bin is defined by the closed interval [right_edge, left_edge]!

Is this a bug, or a design consideration?


More information about the Numpy-discussion mailing list