{"action":"created","comment":{"url":"https://api.github.com/repos/numpy/numpy/pulls/comments/37002058","id":37002058,"diff_hunk":"@@ -158,6 +292,14 @@ def histogram(a, bins=10, range=None, normed=False, weights=None,\n     >>> np.sum(hist*np.diff(bin_edges))\n     1.0\n \n+    Automated Bin Selection Methods example, using 2 peak random data with 2000 points\n+\n+    >>> from matplotlib import pyplot as plt\n+    >>> a = np.hstack((np.random.randn(1000), np.random.randn(1000) * 2 + 5))","path":"numpy/lib/function_base.py","position":175,"original_position":175,"commit_id":"0d72ebf49ed2390d45645e4d960fec2c685bc203","original_commit_id":"0d72ebf49ed2390d45645e4d960fec2c685bc203","user":{"login":"shoyer","id":1217238,"avatar_url":"https://avatars.githubusercontent.com/u/1217238?v=3","gravatar_id":"","url":"https://api.github.com/users/shoyer","html_url":"https://github.com/shoyer","followers_url":"https://api.github.com/users/shoyer/followers","following_url":"https://api.github.com/users/shoyer/following{/other_user}","gists_url":"https://api.github.com/users/shoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/shoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shoyer/subscriptions","organizations_url":"https://api.github.com/users/shoyer/orgs","repos_url":"https://api.github.com/users/shoyer/repos","events_url":"https://api.github.com/users/shoyer/events{/privacy}","received_events_url":"https://api.github.com/users/shoyer/received_events","type":"User","site_admin":false},"body":"Use a `np.random.RandomState` instance to make documentation builds deterministic.\r\n\r\nAlso -- do we actually generate plots from docstrings in the numpy documentation? It's worth checking on this.","created_at":"2015-08-13T17:36:24Z","updated_at":"2015-08-13T17:36:24Z","html_url":"https://github.com/numpy/numpy/pull/6029#discussion_r37002058","pull_request_url":"https://api.github.com/repos/numpy/numpy/pulls/6029","_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments/37002058"},"html":{"href":"https://github.com/numpy/numpy/pull/6029#discussion_r37002058"},"pull_request":{"href":"https://api.github.com/repos/numpy/numpy/pulls/6029"}}},"pull_request":{"url":"https://api.github.com/repos/numpy/numpy/pulls/6029","id":38843376,"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","issue_url":"https://api.github.com/repos/numpy/numpy/issues/6029","number":6029,"state":"open","locked":false,"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},"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. ","created_at":"2015-06-30T05:20:40Z","updated_at":"2015-08-13T17:36:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dbeeab12f12861062e764cf5f6b0575babb9f969","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/numpy/numpy/pulls/6029/commits","review_comments_url":"https://api.github.com/repos/numpy/numpy/pulls/6029/comments","review_comment_url":"https://api.github.com/repos/numpy/numpy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/6029/comments","statuses_url":"https://api.github.com/repos/numpy/numpy/statuses/0d72ebf49ed2390d45645e4d960fec2c685bc203","head":{"label":"nayyarv:master","ref":"master","sha":"0d72ebf49ed2390d45645e4d960fec2c685bc203","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},"repo":{"id":38287266,"name":"numpy","full_name":"nayyarv/numpy","owner":{"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},"private":false,"html_url":"https://github.com/nayyarv/numpy","description":"Numpy main repository","fork":true,"url":"https://api.github.com/repos/nayyarv/numpy","forks_url":"https://api.github.com/repos/nayyarv/numpy/forks","keys_url":"https://api.github.com/repos/nayyarv/numpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nayyarv/numpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nayyarv/numpy/teams","hooks_url":"https://api.github.com/repos/nayyarv/numpy/hooks","issue_events_url":"https://api.github.com/repos/nayyarv/numpy/issues/events{/number}","events_url":"https://api.github.com/repos/nayyarv/numpy/events","assignees_url":"https://api.github.com/repos/nayyarv/numpy/assignees{/user}","branches_url":"https://api.github.com/repos/nayyarv/numpy/branches{/branch}","tags_url":"https://api.github.com/repos/nayyarv/numpy/tags","blobs_url":"https://api.github.com/repos/nayyarv/numpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nayyarv/numpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nayyarv/numpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/nayyarv/numpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nayyarv/numpy/statuses/{sha}","languages_url":"https://api.github.com/repos/nayyarv/numpy/languages","stargazers_url":"https://api.github.com/repos/nayyarv/numpy/stargazers","contributors_url":"https://api.github.com/repos/nayyarv/numpy/contributors","subscribers_url":"https://api.github.com/repos/nayyarv/numpy/subscribers","subscription_url":"https://api.github.com/repos/nayyarv/numpy/subscription","commits_url":"https://api.github.com/repos/nayyarv/numpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/nayyarv/numpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/nayyarv/numpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/nayyarv/numpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/nayyarv/numpy/contents/{+path}","compare_url":"https://api.github.com/repos/nayyarv/numpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nayyarv/numpy/merges","archive_url":"https://api.github.com/repos/nayyarv/numpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nayyarv/numpy/downloads","issues_url":"https://api.github.com/repos/nayyarv/numpy/issues{/number}","pulls_url":"https://api.github.com/repos/nayyarv/numpy/pulls{/number}","milestones_url":"https://api.github.com/repos/nayyarv/numpy/milestones{/number}","notifications_url":"https://api.github.com/repos/nayyarv/numpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nayyarv/numpy/labels{/name}","releases_url":"https://api.github.com/repos/nayyarv/numpy/releases{/id}","created_at":"2015-06-30T04:11:16Z","updated_at":"2015-06-30T04:11:20Z","pushed_at":"2015-08-10T00:44:31Z","git_url":"git://github.com/nayyarv/numpy.git","ssh_url":"git@github.com:nayyarv/numpy.git","clone_url":"https://github.com/nayyarv/numpy.git","svn_url":"https://github.com/nayyarv/numpy","homepage":"http://www.numpy.org/","size":40582,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"numpy:master","ref":"master","sha":"fe0cb80d225508813de21e048c2f1529c2dc6a75","user":{"login":"numpy","id":288276,"avatar_url":"https://avatars.githubusercontent.com/u/288276?v=3","gravatar_id":"","url":"https://api.github.com/users/numpy","html_url":"https://github.com/numpy","followers_url":"https://api.github.com/users/numpy/followers","following_url":"https://api.github.com/users/numpy/following{/other_user}","gists_url":"https://api.github.com/users/numpy/gists{/gist_id}","starred_url":"https://api.github.com/users/numpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/numpy/subscriptions","organizations_url":"https://api.github.com/users/numpy/orgs","repos_url":"https://api.github.com/users/numpy/repos","events_url":"https://api.github.com/users/numpy/events{/privacy}","received_events_url":"https://api.github.com/users/numpy/received_events","type":"Organization","site_admin":false},"repo":{"id":908607,"name":"numpy","full_name":"numpy/numpy","owner":{"login":"numpy","id":288276,"avatar_url":"https://avatars.githubusercontent.com/u/288276?v=3","gravatar_id":"","url":"https://api.github.com/users/numpy","html_url":"https://github.com/numpy","followers_url":"https://api.github.com/users/numpy/followers","following_url":"https://api.github.com/users/numpy/following{/other_user}","gists_url":"https://api.github.com/users/numpy/gists{/gist_id}","starred_url":"https://api.github.com/users/numpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/numpy/subscriptions","organizations_url":"https://api.github.com/users/numpy/orgs","repos_url":"https://api.github.com/users/numpy/repos","events_url":"https://api.github.com/users/numpy/events{/privacy}","received_events_url":"https://api.github.com/users/numpy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/numpy/numpy","description":"Numpy main repository","fork":false,"url":"https://api.github.com/repos/numpy/numpy","forks_url":"https://api.github.com/repos/numpy/numpy/forks","keys_url":"https://api.github.com/repos/numpy/numpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/numpy/numpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/numpy/numpy/teams","hooks_url":"https://api.github.com/repos/numpy/numpy/hooks","issue_events_url":"https://api.github.com/repos/numpy/numpy/issues/events{/number}","events_url":"https://api.github.com/repos/numpy/numpy/events","assignees_url":"https://api.github.com/repos/numpy/numpy/assignees{/user}","branches_url":"https://api.github.com/repos/numpy/numpy/branches{/branch}","tags_url":"https://api.github.com/repos/numpy/numpy/tags","blobs_url":"https://api.github.com/repos/numpy/numpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/numpy/numpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/numpy/numpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/numpy/numpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/numpy/numpy/statuses/{sha}","languages_url":"https://api.github.com/repos/numpy/numpy/languages","stargazers_url":"https://api.github.com/repos/numpy/numpy/stargazers","contributors_url":"https://api.github.com/repos/numpy/numpy/contributors","subscribers_url":"https://api.github.com/repos/numpy/numpy/subscribers","subscription_url":"https://api.github.com/repos/numpy/numpy/subscription","commits_url":"https://api.github.com/repos/numpy/numpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/numpy/numpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/numpy/numpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/numpy/numpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/numpy/numpy/contents/{+path}","compare_url":"https://api.github.com/repos/numpy/numpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/numpy/numpy/merges","archive_url":"https://api.github.com/repos/numpy/numpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/numpy/numpy/downloads","issues_url":"https://api.github.com/repos/numpy/numpy/issues{/number}","pulls_url":"https://api.github.com/repos/numpy/numpy/pulls{/number}","milestones_url":"https://api.github.com/repos/numpy/numpy/milestones{/number}","notifications_url":"https://api.github.com/repos/numpy/numpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/numpy/numpy/labels{/name}","releases_url":"https://api.github.com/repos/numpy/numpy/releases{/id}","created_at":"2010-09-13T23:02:39Z","updated_at":"2015-08-13T15:03:36Z","pushed_at":"2015-08-13T14:53:50Z","git_url":"git://github.com/numpy/numpy.git","ssh_url":"git@github.com:numpy/numpy.git","clone_url":"https://github.com/numpy/numpy.git","svn_url":"https://github.com/numpy/numpy","homepage":"http://www.numpy.org/","size":81965,"stargazers_count":2122,"watchers_count":2122,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1087,"mirror_url":null,"open_issues_count":944,"forks":1087,"open_issues":944,"watchers":2122,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/6029"},"html":{"href":"https://github.com/numpy/numpy/pull/6029"},"issue":{"href":"https://api.github.com/repos/numpy/numpy/issues/6029"},"comments":{"href":"https://api.github.com/repos/numpy/numpy/issues/6029/comments"},"review_comments":{"href":"https://api.github.com/repos/numpy/numpy/pulls/6029/comments"},"review_comment":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/numpy/numpy/pulls/6029/commits"},"statuses":{"href":"https://api.github.com/repos/numpy/numpy/statuses/0d72ebf49ed2390d45645e4d960fec2c685bc203"}}}}