{"action":"created","comment":{"url":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls/comments/57470180","id":57470180,"diff_hunk":"@@ -0,0 +1,60 @@\n+package macrobase.analysis.stats.distribution;\n+\n+import org.apache.commons.math3.linear.LUDecomposition;\n+import org.apache.commons.math3.linear.MatrixUtils;\n+import org.apache.commons.math3.linear.RealMatrix;\n+import org.apache.commons.math3.linear.RealVector;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+public class MultivariateTDistribution {\n+    private static final Logger log = LoggerFactory.getLogger(MultivariateTDistribution.class);\n+    private RealVector mean;\n+    private RealMatrix covarianceMatrix;\n+    private RealMatrix precisionMatrix;\n+    private double degreesOfFreedom;\n+\n+    private int dimensions;\n+    private double multiplier;\n+\n+    public MultivariateTDistribution(RealVector mean, RealMatrix covarianceMatrix, int degreesOfFreedom) {\n+        this.mean = mean;\n+        this.covarianceMatrix = covarianceMatrix;\n+        if (mean.getDimension() > 1) {\n+            this.precisionMatrix = MatrixUtils.blockInverse(covarianceMatrix, (-1 + covarianceMatrix.getColumnDimension()) / 2);\n+        } else {\n+            this.precisionMatrix = MatrixUtils.createRealIdentityMatrix(1).scalarMultiply(1. / covarianceMatrix.getEntry(0, 0));\n+        }\n+        this.degreesOfFreedom = degreesOfFreedom;\n+\n+        this.dimensions = mean.getDimension();\n+\n+        double determinant = new LUDecomposition(covarianceMatrix).getDeterminant();\n+\n+        this.multiplier = halfGammaRatio(dimensions + degreesOfFreedom, degreesOfFreedom)/\n+                Math.pow(Math.PI * degreesOfFreedom, 0.5 * dimensions) /\n+                Math.pow(determinant, 0.5);\n+    }\n+\n+\n+    public double density(RealVector vector) {","path":"src/main/java/macrobase/analysis/stats/distribution/MultivariateTDistribution.java","position":40,"original_position":40,"commit_id":"38b7dfa2d4bd7ce1039c01a6022d98c1ff7b2330","original_commit_id":"38b7dfa2d4bd7ce1039c01a6022d98c1ff7b2330","user":{"login":"pbailis","id":970191,"avatar_url":"https://avatars.githubusercontent.com/u/970191?v=3","gravatar_id":"","url":"https://api.github.com/users/pbailis","html_url":"https://github.com/pbailis","followers_url":"https://api.github.com/users/pbailis/followers","following_url":"https://api.github.com/users/pbailis/following{/other_user}","gists_url":"https://api.github.com/users/pbailis/gists{/gist_id}","starred_url":"https://api.github.com/users/pbailis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbailis/subscriptions","organizations_url":"https://api.github.com/users/pbailis/orgs","repos_url":"https://api.github.com/users/pbailis/repos","events_url":"https://api.github.com/users/pbailis/events{/privacy}","received_events_url":"https://api.github.com/users/pbailis/received_events","type":"User","site_admin":false},"body":"Do we want to have a more generic distribution class?","created_at":"2016-03-25T17:54:27Z","updated_at":"2016-03-25T17:54:27Z","html_url":"https://github.com/stanford-futuredata/macrobase/pull/99#discussion_r57470180","pull_request_url":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls/99","_links":{"self":{"href":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls/comments/57470180"},"html":{"href":"https://github.com/stanford-futuredata/macrobase/pull/99#discussion_r57470180"},"pull_request":{"href":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls/99"}}},"pull_request":{"url":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls/99","id":63672367,"html_url":"https://github.com/stanford-futuredata/macrobase/pull/99","diff_url":"https://github.com/stanford-futuredata/macrobase/pull/99.diff","patch_url":"https://github.com/stanford-futuredata/macrobase/pull/99.patch","issue_url":"https://api.github.com/repos/stanford-futuredata/macrobase/issues/99","number":99,"state":"open","locked":false,"title":"Add Bayesian Normal Density estimator","user":{"login":"mamikonyana","id":2184519,"avatar_url":"https://avatars.githubusercontent.com/u/2184519?v=3","gravatar_id":"","url":"https://api.github.com/users/mamikonyana","html_url":"https://github.com/mamikonyana","followers_url":"https://api.github.com/users/mamikonyana/followers","following_url":"https://api.github.com/users/mamikonyana/following{/other_user}","gists_url":"https://api.github.com/users/mamikonyana/gists{/gist_id}","starred_url":"https://api.github.com/users/mamikonyana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mamikonyana/subscriptions","organizations_url":"https://api.github.com/users/mamikonyana/orgs","repos_url":"https://api.github.com/users/mamikonyana/repos","events_url":"https://api.github.com/users/mamikonyana/events{/privacy}","received_events_url":"https://api.github.com/users/mamikonyana/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-22T05:42:55Z","updated_at":"2016-03-25T17:54:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9cd85a8f04a00403cce55a9715fe2943d963856c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls/99/commits","review_comments_url":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls/99/comments","review_comment_url":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stanford-futuredata/macrobase/issues/99/comments","statuses_url":"https://api.github.com/repos/stanford-futuredata/macrobase/statuses/38b7dfa2d4bd7ce1039c01a6022d98c1ff7b2330","head":{"label":"stanford-futuredata:bayesianNormal","ref":"bayesianNormal","sha":"38b7dfa2d4bd7ce1039c01a6022d98c1ff7b2330","user":{"login":"stanford-futuredata","id":16332752,"avatar_url":"https://avatars.githubusercontent.com/u/16332752?v=3","gravatar_id":"","url":"https://api.github.com/users/stanford-futuredata","html_url":"https://github.com/stanford-futuredata","followers_url":"https://api.github.com/users/stanford-futuredata/followers","following_url":"https://api.github.com/users/stanford-futuredata/following{/other_user}","gists_url":"https://api.github.com/users/stanford-futuredata/gists{/gist_id}","starred_url":"https://api.github.com/users/stanford-futuredata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stanford-futuredata/subscriptions","organizations_url":"https://api.github.com/users/stanford-futuredata/orgs","repos_url":"https://api.github.com/users/stanford-futuredata/repos","events_url":"https://api.github.com/users/stanford-futuredata/events{/privacy}","received_events_url":"https://api.github.com/users/stanford-futuredata/received_events","type":"Organization","site_admin":false},"repo":{"id":48199522,"name":"macrobase","full_name":"stanford-futuredata/macrobase","owner":{"login":"stanford-futuredata","id":16332752,"avatar_url":"https://avatars.githubusercontent.com/u/16332752?v=3","gravatar_id":"","url":"https://api.github.com/users/stanford-futuredata","html_url":"https://github.com/stanford-futuredata","followers_url":"https://api.github.com/users/stanford-futuredata/followers","following_url":"https://api.github.com/users/stanford-futuredata/following{/other_user}","gists_url":"https://api.github.com/users/stanford-futuredata/gists{/gist_id}","starred_url":"https://api.github.com/users/stanford-futuredata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stanford-futuredata/subscriptions","organizations_url":"https://api.github.com/users/stanford-futuredata/orgs","repos_url":"https://api.github.com/users/stanford-futuredata/repos","events_url":"https://api.github.com/users/stanford-futuredata/events{/privacy}","received_events_url":"https://api.github.com/users/stanford-futuredata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/stanford-futuredata/macrobase","description":"http://macrobase.io/","fork":false,"url":"https://api.github.com/repos/stanford-futuredata/macrobase","forks_url":"https://api.github.com/repos/stanford-futuredata/macrobase/forks","keys_url":"https://api.github.com/repos/stanford-futuredata/macrobase/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stanford-futuredata/macrobase/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stanford-futuredata/macrobase/teams","hooks_url":"https://api.github.com/repos/stanford-futuredata/macrobase/hooks","issue_events_url":"https://api.github.com/repos/stanford-futuredata/macrobase/issues/events{/number}","events_url":"https://api.github.com/repos/stanford-futuredata/macrobase/events","assignees_url":"https://api.github.com/repos/stanford-futuredata/macrobase/assignees{/user}","branches_url":"https://api.github.com/repos/stanford-futuredata/macrobase/branches{/branch}","tags_url":"https://api.github.com/repos/stanford-futuredata/macrobase/tags","blobs_url":"https://api.github.com/repos/stanford-futuredata/macrobase/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stanford-futuredata/macrobase/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stanford-futuredata/macrobase/git/refs{/sha}","trees_url":"https://api.github.com/repos/stanford-futuredata/macrobase/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stanford-futuredata/macrobase/statuses/{sha}","languages_url":"https://api.github.com/repos/stanford-futuredata/macrobase/languages","stargazers_url":"https://api.github.com/repos/stanford-futuredata/macrobase/stargazers","contributors_url":"https://api.github.com/repos/stanford-futuredata/macrobase/contributors","subscribers_url":"https://api.github.com/repos/stanford-futuredata/macrobase/subscribers","subscription_url":"https://api.github.com/repos/stanford-futuredata/macrobase/subscription","commits_url":"https://api.github.com/repos/stanford-futuredata/macrobase/commits{/sha}","git_commits_url":"https://api.github.com/repos/stanford-futuredata/macrobase/git/commits{/sha}","comments_url":"https://api.github.com/repos/stanford-futuredata/macrobase/comments{/number}","issue_comment_url":"https://api.github.com/repos/stanford-futuredata/macrobase/issues/comments{/number}","contents_url":"https://api.github.com/repos/stanford-futuredata/macrobase/contents/{+path}","compare_url":"https://api.github.com/repos/stanford-futuredata/macrobase/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stanford-futuredata/macrobase/merges","archive_url":"https://api.github.com/repos/stanford-futuredata/macrobase/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stanford-futuredata/macrobase/downloads","issues_url":"https://api.github.com/repos/stanford-futuredata/macrobase/issues{/number}","pulls_url":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls{/number}","milestones_url":"https://api.github.com/repos/stanford-futuredata/macrobase/milestones{/number}","notifications_url":"https://api.github.com/repos/stanford-futuredata/macrobase/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stanford-futuredata/macrobase/labels{/name}","releases_url":"https://api.github.com/repos/stanford-futuredata/macrobase/releases{/id}","deployments_url":"https://api.github.com/repos/stanford-futuredata/macrobase/deployments","created_at":"2015-12-17T21:36:20Z","updated_at":"2016-03-24T15:46:36Z","pushed_at":"2016-03-23T19:04:53Z","git_url":"git://github.com/stanford-futuredata/macrobase.git","ssh_url":"git@github.com:stanford-futuredata/macrobase.git","clone_url":"https://github.com/stanford-futuredata/macrobase.git","svn_url":"https://github.com/stanford-futuredata/macrobase","homepage":null,"size":3462,"stargazers_count":59,"watchers_count":59,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":1,"forks":8,"open_issues":1,"watchers":59,"default_branch":"master"}},"base":{"label":"stanford-futuredata:master","ref":"master","sha":"be7ec864e3d82b3775fc02d6ca5ede6e480df906","user":{"login":"stanford-futuredata","id":16332752,"avatar_url":"https://avatars.githubusercontent.com/u/16332752?v=3","gravatar_id":"","url":"https://api.github.com/users/stanford-futuredata","html_url":"https://github.com/stanford-futuredata","followers_url":"https://api.github.com/users/stanford-futuredata/followers","following_url":"https://api.github.com/users/stanford-futuredata/following{/other_user}","gists_url":"https://api.github.com/users/stanford-futuredata/gists{/gist_id}","starred_url":"https://api.github.com/users/stanford-futuredata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stanford-futuredata/subscriptions","organizations_url":"https://api.github.com/users/stanford-futuredata/orgs","repos_url":"https://api.github.com/users/stanford-futuredata/repos","events_url":"https://api.github.com/users/stanford-futuredata/events{/privacy}","received_events_url":"https://api.github.com/users/stanford-futuredata/received_events","type":"Organization","site_admin":false},"repo":{"id":48199522,"name":"macrobase","full_name":"stanford-futuredata/macrobase","owner":{"login":"stanford-futuredata","id":16332752,"avatar_url":"https://avatars.githubusercontent.com/u/16332752?v=3","gravatar_id":"","url":"https://api.github.com/users/stanford-futuredata","html_url":"https://github.com/stanford-futuredata","followers_url":"https://api.github.com/users/stanford-futuredata/followers","following_url":"https://api.github.com/users/stanford-futuredata/following{/other_user}","gists_url":"https://api.github.com/users/stanford-futuredata/gists{/gist_id}","starred_url":"https://api.github.com/users/stanford-futuredata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stanford-futuredata/subscriptions","organizations_url":"https://api.github.com/users/stanford-futuredata/orgs","repos_url":"https://api.github.com/users/stanford-futuredata/repos","events_url":"https://api.github.com/users/stanford-futuredata/events{/privacy}","received_events_url":"https://api.github.com/users/stanford-futuredata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/stanford-futuredata/macrobase","description":"http://macrobase.io/","fork":false,"url":"https://api.github.com/repos/stanford-futuredata/macrobase","forks_url":"https://api.github.com/repos/stanford-futuredata/macrobase/forks","keys_url":"https://api.github.com/repos/stanford-futuredata/macrobase/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stanford-futuredata/macrobase/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stanford-futuredata/macrobase/teams","hooks_url":"https://api.github.com/repos/stanford-futuredata/macrobase/hooks","issue_events_url":"https://api.github.com/repos/stanford-futuredata/macrobase/issues/events{/number}","events_url":"https://api.github.com/repos/stanford-futuredata/macrobase/events","assignees_url":"https://api.github.com/repos/stanford-futuredata/macrobase/assignees{/user}","branches_url":"https://api.github.com/repos/stanford-futuredata/macrobase/branches{/branch}","tags_url":"https://api.github.com/repos/stanford-futuredata/macrobase/tags","blobs_url":"https://api.github.com/repos/stanford-futuredata/macrobase/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stanford-futuredata/macrobase/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stanford-futuredata/macrobase/git/refs{/sha}","trees_url":"https://api.github.com/repos/stanford-futuredata/macrobase/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stanford-futuredata/macrobase/statuses/{sha}","languages_url":"https://api.github.com/repos/stanford-futuredata/macrobase/languages","stargazers_url":"https://api.github.com/repos/stanford-futuredata/macrobase/stargazers","contributors_url":"https://api.github.com/repos/stanford-futuredata/macrobase/contributors","subscribers_url":"https://api.github.com/repos/stanford-futuredata/macrobase/subscribers","subscription_url":"https://api.github.com/repos/stanford-futuredata/macrobase/subscription","commits_url":"https://api.github.com/repos/stanford-futuredata/macrobase/commits{/sha}","git_commits_url":"https://api.github.com/repos/stanford-futuredata/macrobase/git/commits{/sha}","comments_url":"https://api.github.com/repos/stanford-futuredata/macrobase/comments{/number}","issue_comment_url":"https://api.github.com/repos/stanford-futuredata/macrobase/issues/comments{/number}","contents_url":"https://api.github.com/repos/stanford-futuredata/macrobase/contents/{+path}","compare_url":"https://api.github.com/repos/stanford-futuredata/macrobase/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stanford-futuredata/macrobase/merges","archive_url":"https://api.github.com/repos/stanford-futuredata/macrobase/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stanford-futuredata/macrobase/downloads","issues_url":"https://api.github.com/repos/stanford-futuredata/macrobase/issues{/number}","pulls_url":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls{/number}","milestones_url":"https://api.github.com/repos/stanford-futuredata/macrobase/milestones{/number}","notifications_url":"https://api.github.com/repos/stanford-futuredata/macrobase/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stanford-futuredata/macrobase/labels{/name}","releases_url":"https://api.github.com/repos/stanford-futuredata/macrobase/releases{/id}","deployments_url":"https://api.github.com/repos/stanford-futuredata/macrobase/deployments","created_at":"2015-12-17T21:36:20Z","updated_at":"2016-03-24T15:46:36Z","pushed_at":"2016-03-23T19:04:53Z","git_url":"git://github.com/stanford-futuredata/macrobase.git","ssh_url":"git@github.com:stanford-futuredata/macrobase.git","clone_url":"https://github.com/stanford-futuredata/macrobase.git","svn_url":"https://github.com/stanford-futuredata/macrobase","homepage":null,"size":3462,"stargazers_count":59,"watchers_count":59,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":1,"forks":8,"open_issues":1,"watchers":59,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls/99"},"html":{"href":"https://github.com/stanford-futuredata/macrobase/pull/99"},"issue":{"href":"https://api.github.com/repos/stanford-futuredata/macrobase/issues/99"},"comments":{"href":"https://api.github.com/repos/stanford-futuredata/macrobase/issues/99/comments"},"review_comments":{"href":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls/99/comments"},"review_comment":{"href":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stanford-futuredata/macrobase/pulls/99/commits"},"statuses":{"href":"https://api.github.com/repos/stanford-futuredata/macrobase/statuses/38b7dfa2d4bd7ce1039c01a6022d98c1ff7b2330"}}}}