{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls/comments/32160066","id":32160066,"diff_hunk":"@@ -226,3 +226,95 @@ wt = [-1, -1, -1, -1, -1]\n @test_throws ErrorException median(data, weights(wt))\n wt = [-1, -1, -1, 0, 0]\n @test_throws ErrorException median(data, weights(wt))\n+\n+\n+\n+\n+# Weighted quantile tests\n+data = (\n+    [7, 1, 2, 4, 10],\n+    [7, 1, 2, 4, 10],\n+    [7, 1, 2, 4, 10, 15],\n+    [1, 2, 4, 7, 10, 15],\n+    [0, 10, 20, 30],\n+    [1, 2, 3, 4, 5],\n+    [1, 2, 3, 4, 5],\n+    [30, 40, 50, 60, 35],\n+    [3.7, 3.3, 3.5, 2.8],\n+    [100, 125, 123, 60, 45, 56, 66],\n+    [2, 2, 2, 2, 2, 2],\n+    [2.3],\n+    [-2, -3, 1, 2, -10],\n+    [1, 2, 3, 4, 5],\n+    [5, 4, 3, 2, 1],\n+    [-2, 2, -1, 3, 6],\n+    [-10, 1, 1, -10, -10],\n+)\n+wt = (\n+    [1, 1/3, 1/3, 1/3, 1],\n+    [1, 1, 1, 1, 1],\n+    [1, 1/3, 1/3, 1/3, 1, 1],\n+    [1/3, 1/3, 1/3, 1, 1, 1],\n+    [30, 191, 9, 0],\n+    [10, 1, 1, 1, 9],\n+    [10, 1, 1, 1, 900],\n+    [1, 3, 5, 4, 2],\n+    [5, 5, 4, 1],\n+    [30, 56, 144, 24, 55, 43, 67],\n+    [0.1, 0.2, 0.3, 0.4, 0.5, 0.6],\n+    [12],\n+    [7, 1, 1, 1, 6],\n+    [1, 0, 0, 0, 2],\n+    [1, 2, 3, 4, 5],\n+    [0.1, 0.2, 0.3, 0.2, 0.1],\n+    [1, 1, 1, 1, 1],\n+)\n+quantile_answers = (    \n+    [1.4444444444444444,5.0,7.999999999999999,9.0,10.0],\n+    [1.0,2.0,4.0,7.0,10.0],\n+    [1.9999999999999998,6.25,8.5,11.249999999999998,15.0],\n+    [1.9999999999999998,6.25,8.5,11.249999999999998,15.0],\n+    [4.782608695652174,12.282608695652172,19.782608695652172,27.282608695652172,30.0],\n+    [1.0,1.0,4.045454545454545,5.045454545454546,5.0],\n+    [4.928806133625411,5.92880613362541,6.928806133625411,7.928806133625409,5.0],\n+    [35.0,40.0,50.0,53.333333333333336,60.0],\n+    [3.166666666666666,3.3299999999999996,3.48,3.616666666666667,3.6999999999999993],\n+    [45.89260143198091,62.7708830548926,107.84964200477326,142.34964200477327,125.0],\n+    [2.0,2.0,2.0,2.0,2.0],\n+    [2.3,2.3,2.3,2.3,2.3],\n+    [-10.0,-9.124999999999998,-2.1875,-1.1874999999999996,2.0],\n+    [1.0,4.333333333333333,5.333333333333333,6.333333333333334,5.0],\n+    [1.0,1.3333333333333335,2.0,3.0,5.0],\n+    [-1.5555555555555558,-0.5555555555555558,1.3333333333333324,2.666666666666666,6.0],\n+    [-10.0,-10.0,-10.0,1.0,1.0],\n+)\n+\n+\n+\n+\n+# w = 1 corresponds to base quantile\n+for i = 1:length(data)\n+    for j = 1:100\n+        q = rand(length(data[i]))","path":"test/weights.jl","position":73,"original_position":73,"commit_id":"83ad4e6f45191a3cd6580406f6e531b97f9d28c6","original_commit_id":"83ad4e6f45191a3cd6580406f6e531b97f9d28c6","user":{"login":"nalimilan","id":1120448,"avatar_url":"https://avatars.githubusercontent.com/u/1120448?v=3","gravatar_id":"","url":"https://api.github.com/users/nalimilan","html_url":"https://github.com/nalimilan","followers_url":"https://api.github.com/users/nalimilan/followers","following_url":"https://api.github.com/users/nalimilan/following{/other_user}","gists_url":"https://api.github.com/users/nalimilan/gists{/gist_id}","starred_url":"https://api.github.com/users/nalimilan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nalimilan/subscriptions","organizations_url":"https://api.github.com/users/nalimilan/orgs","repos_url":"https://api.github.com/users/nalimilan/repos","events_url":"https://api.github.com/users/nalimilan/events{/privacy}","received_events_url":"https://api.github.com/users/nalimilan/received_events","type":"User","site_admin":false},"body":"I don't think tests on random data are really appreciated around here. Getting errors at random can be confusing, especially given that testing has been quite unstable for some time. You should probably add a call to `srand`, which people can remove to test the algorithm more extensively. But others will likely comment.","created_at":"2015-06-10T20:04:52Z","updated_at":"2015-06-10T20:04:52Z","html_url":"https://github.com/JuliaStats/StatsBase.jl/pull/117#discussion_r32160066","pull_request_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls/117","_links":{"self":{"href":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls/comments/32160066"},"html":{"href":"https://github.com/JuliaStats/StatsBase.jl/pull/117#discussion_r32160066"},"pull_request":{"href":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls/117"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls/117","id":37379920,"html_url":"https://github.com/JuliaStats/StatsBase.jl/pull/117","diff_url":"https://github.com/JuliaStats/StatsBase.jl/pull/117.diff","patch_url":"https://github.com/JuliaStats/StatsBase.jl/pull/117.patch","issue_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/issues/117","number":117,"state":"open","locked":false,"title":"wquantile","user":{"login":"matthieugomez","id":6223837,"avatar_url":"https://avatars.githubusercontent.com/u/6223837?v=3","gravatar_id":"","url":"https://api.github.com/users/matthieugomez","html_url":"https://github.com/matthieugomez","followers_url":"https://api.github.com/users/matthieugomez/followers","following_url":"https://api.github.com/users/matthieugomez/following{/other_user}","gists_url":"https://api.github.com/users/matthieugomez/gists{/gist_id}","starred_url":"https://api.github.com/users/matthieugomez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthieugomez/subscriptions","organizations_url":"https://api.github.com/users/matthieugomez/orgs","repos_url":"https://api.github.com/users/matthieugomez/repos","events_url":"https://api.github.com/users/matthieugomez/events{/privacy}","received_events_url":"https://api.github.com/users/matthieugomez/received_events","type":"User","site_admin":false},"body":"This function implements a weighted quantile. It is a generalization of quantile type 7 as implemented in Julia base (by that I mean results are the same with w = 1). \r\n\r\nThe function follows the notation in the R help file for quantile, which hopefully will make it easy to add more quantile types. Only non negative weights are allowed.\r\n\r\nI've added some tests and documentation.\r\n\r\nThis is my first pull request so I may be doing some things incorrectly. In particular, I'm not sure about the order of arguments (weight vs quantiles).","created_at":"2015-06-10T16:49:32Z","updated_at":"2015-06-10T20:04:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3dedc7fe877af4f400eef95d73824a5f66560284","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls/117/commits","review_comments_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls/117/comments","review_comment_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/issues/117/comments","statuses_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/statuses/83ad4e6f45191a3cd6580406f6e531b97f9d28c6","head":{"label":"matthieugomez:master","ref":"master","sha":"83ad4e6f45191a3cd6580406f6e531b97f9d28c6","user":{"login":"matthieugomez","id":6223837,"avatar_url":"https://avatars.githubusercontent.com/u/6223837?v=3","gravatar_id":"","url":"https://api.github.com/users/matthieugomez","html_url":"https://github.com/matthieugomez","followers_url":"https://api.github.com/users/matthieugomez/followers","following_url":"https://api.github.com/users/matthieugomez/following{/other_user}","gists_url":"https://api.github.com/users/matthieugomez/gists{/gist_id}","starred_url":"https://api.github.com/users/matthieugomez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthieugomez/subscriptions","organizations_url":"https://api.github.com/users/matthieugomez/orgs","repos_url":"https://api.github.com/users/matthieugomez/repos","events_url":"https://api.github.com/users/matthieugomez/events{/privacy}","received_events_url":"https://api.github.com/users/matthieugomez/received_events","type":"User","site_admin":false},"repo":{"id":37195964,"name":"StatsBase.jl","full_name":"matthieugomez/StatsBase.jl","owner":{"login":"matthieugomez","id":6223837,"avatar_url":"https://avatars.githubusercontent.com/u/6223837?v=3","gravatar_id":"","url":"https://api.github.com/users/matthieugomez","html_url":"https://github.com/matthieugomez","followers_url":"https://api.github.com/users/matthieugomez/followers","following_url":"https://api.github.com/users/matthieugomez/following{/other_user}","gists_url":"https://api.github.com/users/matthieugomez/gists{/gist_id}","starred_url":"https://api.github.com/users/matthieugomez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthieugomez/subscriptions","organizations_url":"https://api.github.com/users/matthieugomez/orgs","repos_url":"https://api.github.com/users/matthieugomez/repos","events_url":"https://api.github.com/users/matthieugomez/events{/privacy}","received_events_url":"https://api.github.com/users/matthieugomez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matthieugomez/StatsBase.jl","description":"Basic statistics for Julia","fork":true,"url":"https://api.github.com/repos/matthieugomez/StatsBase.jl","forks_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/forks","keys_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/teams","hooks_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/hooks","issue_events_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/issues/events{/number}","events_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/events","assignees_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/assignees{/user}","branches_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/branches{/branch}","tags_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/tags","blobs_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/languages","stargazers_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/stargazers","contributors_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/contributors","subscribers_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/subscribers","subscription_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/subscription","commits_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/contents/{+path}","compare_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/merges","archive_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/downloads","issues_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/issues{/number}","pulls_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/labels{/name}","releases_url":"https://api.github.com/repos/matthieugomez/StatsBase.jl/releases{/id}","created_at":"2015-06-10T12:31:44Z","updated_at":"2015-06-10T12:31:45Z","pushed_at":"2015-06-10T18:24:59Z","git_url":"git://github.com/matthieugomez/StatsBase.jl.git","ssh_url":"git@github.com:matthieugomez/StatsBase.jl.git","clone_url":"https://github.com/matthieugomez/StatsBase.jl.git","svn_url":"https://github.com/matthieugomez/StatsBase.jl","homepage":null,"size":471,"stargazers_count":0,"watchers_count":0,"language":"Julia","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":"JuliaStats:master","ref":"master","sha":"23b36af460cfd6c147efef9074a76a4e8cf13dae","user":{"login":"JuliaStats","id":2761531,"avatar_url":"https://avatars.githubusercontent.com/u/2761531?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaStats","html_url":"https://github.com/JuliaStats","followers_url":"https://api.github.com/users/JuliaStats/followers","following_url":"https://api.github.com/users/JuliaStats/following{/other_user}","gists_url":"https://api.github.com/users/JuliaStats/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaStats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaStats/subscriptions","organizations_url":"https://api.github.com/users/JuliaStats/orgs","repos_url":"https://api.github.com/users/JuliaStats/repos","events_url":"https://api.github.com/users/JuliaStats/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaStats/received_events","type":"Organization","site_admin":false},"repo":{"id":8130810,"name":"StatsBase.jl","full_name":"JuliaStats/StatsBase.jl","owner":{"login":"JuliaStats","id":2761531,"avatar_url":"https://avatars.githubusercontent.com/u/2761531?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaStats","html_url":"https://github.com/JuliaStats","followers_url":"https://api.github.com/users/JuliaStats/followers","following_url":"https://api.github.com/users/JuliaStats/following{/other_user}","gists_url":"https://api.github.com/users/JuliaStats/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaStats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaStats/subscriptions","organizations_url":"https://api.github.com/users/JuliaStats/orgs","repos_url":"https://api.github.com/users/JuliaStats/repos","events_url":"https://api.github.com/users/JuliaStats/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaStats/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaStats/StatsBase.jl","description":"Basic statistics for Julia","fork":false,"url":"https://api.github.com/repos/JuliaStats/StatsBase.jl","forks_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/forks","keys_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/teams","hooks_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/hooks","issue_events_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/events","assignees_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/tags","blobs_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/languages","stargazers_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/stargazers","contributors_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/contributors","subscribers_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/subscribers","subscription_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/subscription","commits_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/merges","archive_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/downloads","issues_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/labels{/name}","releases_url":"https://api.github.com/repos/JuliaStats/StatsBase.jl/releases{/id}","created_at":"2013-02-11T01:22:06Z","updated_at":"2015-06-10T00:33:36Z","pushed_at":"2015-06-10T18:24:59Z","git_url":"git://github.com/JuliaStats/StatsBase.jl.git","ssh_url":"git@github.com:JuliaStats/StatsBase.jl.git","clone_url":"https://github.com/JuliaStats/StatsBase.jl.git","svn_url":"https://github.com/JuliaStats/StatsBase.jl","homepage":null,"size":1813,"stargazers_count":56,"watchers_count":56,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":11,"forks":31,"open_issues":11,"watchers":56,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls/117"},"html":{"href":"https://github.com/JuliaStats/StatsBase.jl/pull/117"},"issue":{"href":"https://api.github.com/repos/JuliaStats/StatsBase.jl/issues/117"},"comments":{"href":"https://api.github.com/repos/JuliaStats/StatsBase.jl/issues/117/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls/117/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaStats/StatsBase.jl/pulls/117/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaStats/StatsBase.jl/statuses/83ad4e6f45191a3cd6580406f6e531b97f9d28c6"}}}}