{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/6029","labels_url":"https://api.github.com/repos/numpy/numpy/issues/6029/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/6029/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/6029/events","html_url":"https://github.com/numpy/numpy/pull/6029","id":91985918,"number":6029,"title":"ENH: Automatic number of bins for np.histogram","user":{"login":"nayyarv","id":1589119,"avatar_url":"https://avatars.githubusercontent.com/u/1589119?v=3","gravatar_id":"","url":"https://api.github.com/users/nayyarv","html_url":"https://github.com/nayyarv","followers_url":"https://api.github.com/users/nayyarv/followers","following_url":"https://api.github.com/users/nayyarv/following{/other_user}","gists_url":"https://api.github.com/users/nayyarv/gists{/gist_id}","starred_url":"https://api.github.com/users/nayyarv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nayyarv/subscriptions","organizations_url":"https://api.github.com/users/nayyarv/orgs","repos_url":"https://api.github.com/users/nayyarv/repos","events_url":"https://api.github.com/users/nayyarv/events{/privacy}","received_events_url":"https://api.github.com/users/nayyarv/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/numpy/numpy/labels/component:%20numpy.lib","name":"component: numpy.lib","color":"ff0000"},{"url":"https://api.github.com/repos/numpy/numpy/labels/Enhancement","name":"Enhancement","color":"e102d8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":19,"created_at":"2015-06-30T05:20:40Z","updated_at":"2015-08-10T02:38:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/numpy/numpy/pulls/6029","html_url":"https://github.com/numpy/numpy/pull/6029","diff_url":"https://github.com/numpy/numpy/pull/6029.diff","patch_url":"https://github.com/numpy/numpy/pull/6029.patch"},"body":"Hi,\r\nBrought this up on the [mailing lists](http://mail.scipy.org/pipermail/numpy-discussion/2015-April/072732.html), and got some support. (It then turned into a discussion of the p-Square algorithm for dynamic histogram generation). I also had some support when I originally brought it up with the matplotlib guys (where I had initially planned to put it), you can find the thread [here](https://github.com/matplotlib/matplotlib/issues/4316)\r\n\r\nI've added support for methods to automatically choose the number of bins based on the data provided. The default signature remains the same, however users can now pass 'auto' or other strings to have an optimal number of bins chosen. This is especially useful for visualisation libraries.\r\n\r\nAn (out of date) notebook with my first code attempts can be found [here](http://nbviewer.ipython.org/github/nayyarv/matplotlib/blob/master/examples/statistics/Automating%20Binwidth%20Choice%20for%20Histogram.ipynb). It discusses the reasoning behind the methods + justification and samples. I've tried to make it slightly simpler since then.\r\n\r\nI've provided the implementation which defines functions within the histogram function as it allows for easy refactoring and I didn't want to put another 5 functions inside the base library that have no use anywhere else. The code is hopefully easy to refactor/change to better fit numpy's style guide/organisation.\r\n\r\nI've included the docstring update as well with some notes on the different methods and a quick example on how to use the new call. I've tested the code and it seems to work as expected so far. Passing in `bins='s'` does lead to choosing the sturges estimator (as opposed to the scott estimator) but I can't say for sure what will happen. "},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/129283676","html_url":"https://github.com/numpy/numpy/pull/6029#issuecomment-129283676","issue_url":"https://api.github.com/repos/numpy/numpy/issues/6029","id":129283676,"user":{"login":"njsmith","id":609896,"avatar_url":"https://avatars.githubusercontent.com/u/609896?v=3","gravatar_id":"","url":"https://api.github.com/users/njsmith","html_url":"https://github.com/njsmith","followers_url":"https://api.github.com/users/njsmith/followers","following_url":"https://api.github.com/users/njsmith/following{/other_user}","gists_url":"https://api.github.com/users/njsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/njsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njsmith/subscriptions","organizations_url":"https://api.github.com/users/njsmith/orgs","repos_url":"https://api.github.com/users/njsmith/repos","events_url":"https://api.github.com/users/njsmith/events{/privacy}","received_events_url":"https://api.github.com/users/njsmith/received_events","type":"User","site_admin":false},"created_at":"2015-08-10T02:38:05Z","updated_at":"2015-08-10T02:38:05Z","body":"I'm happy, but haven't actually reviewed the code so I'll leave it for\nsomeone who has to do the honors :-)\nOn Aug 9, 2015 5:53 PM, \"Varun Nayyar\" <notifications@github.com> wrote:\n\n> Thanks @njsmith <https://github.com/njsmith>, assert_raises did live up\n> to the hype :). Also fixed the {} to be {0} for string formatting in the\n> couple of ValueErrrors I raise.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/numpy/numpy/pull/6029#issuecomment-129265180>.\n>\n"}}