Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

histogram and digitize do not agree on the definition of a bin #5367

Closed
jtbraun opened this issue Oct 30, 2015 · 2 comments
Closed

histogram and digitize do not agree on the definition of a bin #5367

jtbraun opened this issue Oct 30, 2015 · 2 comments

Comments

@jtbraun
Copy link

jtbraun commented Oct 30, 2015

numpy.histogram produces bins such that:

All but the last (righthand-most) bin is half-open. In other words, if bins is:

[1, 2, 3, 4]
then the first bin is [1, 2) (including 1, but excluding 2) and the second [2, 3). The last bin, however, is [3, 4], which includes 4.

numpy.digitize interprets the bin argument as:

Each index i returned is such that bins[i-1] <= x < bins[i] if bins is monotonically increasing, or bins[i-1] > x >= bins[i] if bins is monotonically decreasing.

It would be convenient if numpy.digitize could be configured to interpret bins as the way that numpy.histogram produces them. Maybe change or replace the right argument to be interval=None|'left'|'right'|'leftclosed'|'rightclosed', where 'leftclosed' would behave as numpy.histogram does.

@tacaswell
Copy link
Member

This should be against numpy not against matplotlib 😉 .

@jtbraun
Copy link
Author

jtbraun commented Oct 30, 2015

Jeez, sorry about that. I'll re-file with the correct project. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants