{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/22442436","id":22442436,"diff_hunk":"@@ -17,23 +17,74 @@\n \n package org.apache.spark.mllib.stat.impl\n \n-import breeze.linalg.{DenseVector => DBV, DenseMatrix => DBM, Transpose, det, pinv}\n+import breeze.linalg.{DenseVector => DBV, DenseMatrix => DBM, max, diag, eigSym}\n \n-/** \n-   * Utility class to implement the density function for multivariate Gaussian distribution.\n-   * Breeze provides this functionality, but it requires the Apache Commons Math library,\n-   * so this class is here so-as to not introduce a new dependency in Spark.\n-   */\n+import org.apache.spark.mllib.util.MLUtils\n+\n+/**\n+ * This class provides basic functionality for a Multivariate Gaussian (Normal) Distribution. In\n+ * the event that the covariance matrix is singular, the density will be computed in a\n+ * reduced dimensional subspace under which the distribution is supported.\n+ * (see http://en.wikipedia.org/wiki/Multivariate_normal_distribution#Degenerate_case)","path":"mllib/src/main/scala/org/apache/spark/mllib/stat/impl/MultivariateGaussian.scala","position":18,"original_position":18,"commit_id":"629d9d03e4bfd79410c8e1471e05986970022175","original_commit_id":"629d9d03e4bfd79410c8e1471e05986970022175","user":{"login":"jkbradley","id":5084283,"avatar_url":"https://avatars.githubusercontent.com/u/5084283?v=3","gravatar_id":"","url":"https://api.github.com/users/jkbradley","html_url":"https://github.com/jkbradley","followers_url":"https://api.github.com/users/jkbradley/followers","following_url":"https://api.github.com/users/jkbradley/following{/other_user}","gists_url":"https://api.github.com/users/jkbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/jkbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkbradley/subscriptions","organizations_url":"https://api.github.com/users/jkbradley/orgs","repos_url":"https://api.github.com/users/jkbradley/repos","events_url":"https://api.github.com/users/jkbradley/events{/privacy}","received_events_url":"https://api.github.com/users/jkbradley/received_events","type":"User","site_admin":false},"body":"For link, use double-brackets:\r\n```\r\n(See [[http://en.wikipedia.org/wiki/Multivariate_normal_distribution#Degenerate_case]])\r\n```","created_at":"2015-01-04T20:46:14Z","updated_at":"2015-01-04T20:46:14Z","html_url":"https://github.com/apache/spark/pull/3871#discussion_r22442436","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/3871","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/22442436"},"html":{"href":"https://github.com/apache/spark/pull/3871#discussion_r22442436"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/3871"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/3871","id":26744047,"html_url":"https://github.com/apache/spark/pull/3871","diff_url":"https://github.com/apache/spark/pull/3871.diff","patch_url":"https://github.com/apache/spark/pull/3871.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/3871","number":3871,"state":"open","locked":false,"title":"SPARK-5017 [MLlib] - Use SVD to compute determinant and inverse of covariance matrix","user":{"login":"tgaloppo","id":9467640,"avatar_url":"https://avatars.githubusercontent.com/u/9467640?v=3","gravatar_id":"","url":"https://api.github.com/users/tgaloppo","html_url":"https://github.com/tgaloppo","followers_url":"https://api.github.com/users/tgaloppo/followers","following_url":"https://api.github.com/users/tgaloppo/following{/other_user}","gists_url":"https://api.github.com/users/tgaloppo/gists{/gist_id}","starred_url":"https://api.github.com/users/tgaloppo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgaloppo/subscriptions","organizations_url":"https://api.github.com/users/tgaloppo/orgs","repos_url":"https://api.github.com/users/tgaloppo/repos","events_url":"https://api.github.com/users/tgaloppo/events{/privacy}","received_events_url":"https://api.github.com/users/tgaloppo/received_events","type":"User","site_admin":false},"body":"MultivariateGaussian was calling both pinv() and det() on the covariance matrix, effectively performing two matrix decompositions.  Both values are now computed using the singular value decompositon. Both the pseudo-inverse and the pseudo-determinant are used to guard against singular matrices.","created_at":"2015-01-01T15:38:56Z","updated_at":"2015-01-04T20:46:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6ea385837b3923bf4b5855d08a92fcff0e05b5ac","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/3871/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/3871/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apache/spark/issues/3871/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/629d9d03e4bfd79410c8e1471e05986970022175","head":{"label":"tgaloppo:spark-5017","ref":"spark-5017","sha":"629d9d03e4bfd79410c8e1471e05986970022175","user":{"login":"tgaloppo","id":9467640,"avatar_url":"https://avatars.githubusercontent.com/u/9467640?v=3","gravatar_id":"","url":"https://api.github.com/users/tgaloppo","html_url":"https://github.com/tgaloppo","followers_url":"https://api.github.com/users/tgaloppo/followers","following_url":"https://api.github.com/users/tgaloppo/following{/other_user}","gists_url":"https://api.github.com/users/tgaloppo/gists{/gist_id}","starred_url":"https://api.github.com/users/tgaloppo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgaloppo/subscriptions","organizations_url":"https://api.github.com/users/tgaloppo/orgs","repos_url":"https://api.github.com/users/tgaloppo/repos","events_url":"https://api.github.com/users/tgaloppo/events{/privacy}","received_events_url":"https://api.github.com/users/tgaloppo/received_events","type":"User","site_admin":false},"repo":{"id":25984335,"name":"spark","full_name":"tgaloppo/spark","owner":{"login":"tgaloppo","id":9467640,"avatar_url":"https://avatars.githubusercontent.com/u/9467640?v=3","gravatar_id":"","url":"https://api.github.com/users/tgaloppo","html_url":"https://github.com/tgaloppo","followers_url":"https://api.github.com/users/tgaloppo/followers","following_url":"https://api.github.com/users/tgaloppo/following{/other_user}","gists_url":"https://api.github.com/users/tgaloppo/gists{/gist_id}","starred_url":"https://api.github.com/users/tgaloppo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgaloppo/subscriptions","organizations_url":"https://api.github.com/users/tgaloppo/orgs","repos_url":"https://api.github.com/users/tgaloppo/repos","events_url":"https://api.github.com/users/tgaloppo/events{/privacy}","received_events_url":"https://api.github.com/users/tgaloppo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tgaloppo/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/tgaloppo/spark","forks_url":"https://api.github.com/repos/tgaloppo/spark/forks","keys_url":"https://api.github.com/repos/tgaloppo/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tgaloppo/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tgaloppo/spark/teams","hooks_url":"https://api.github.com/repos/tgaloppo/spark/hooks","issue_events_url":"https://api.github.com/repos/tgaloppo/spark/issues/events{/number}","events_url":"https://api.github.com/repos/tgaloppo/spark/events","assignees_url":"https://api.github.com/repos/tgaloppo/spark/assignees{/user}","branches_url":"https://api.github.com/repos/tgaloppo/spark/branches{/branch}","tags_url":"https://api.github.com/repos/tgaloppo/spark/tags","blobs_url":"https://api.github.com/repos/tgaloppo/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tgaloppo/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tgaloppo/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/tgaloppo/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tgaloppo/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/tgaloppo/spark/languages","stargazers_url":"https://api.github.com/repos/tgaloppo/spark/stargazers","contributors_url":"https://api.github.com/repos/tgaloppo/spark/contributors","subscribers_url":"https://api.github.com/repos/tgaloppo/spark/subscribers","subscription_url":"https://api.github.com/repos/tgaloppo/spark/subscription","commits_url":"https://api.github.com/repos/tgaloppo/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/tgaloppo/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/tgaloppo/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/tgaloppo/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/tgaloppo/spark/contents/{+path}","compare_url":"https://api.github.com/repos/tgaloppo/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tgaloppo/spark/merges","archive_url":"https://api.github.com/repos/tgaloppo/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tgaloppo/spark/downloads","issues_url":"https://api.github.com/repos/tgaloppo/spark/issues{/number}","pulls_url":"https://api.github.com/repos/tgaloppo/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/tgaloppo/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/tgaloppo/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tgaloppo/spark/labels{/name}","releases_url":"https://api.github.com/repos/tgaloppo/spark/releases{/id}","created_at":"2014-10-30T18:30:09Z","updated_at":"2015-01-01T00:02:16Z","pushed_at":"2015-01-03T20:01:04Z","git_url":"git://github.com/tgaloppo/spark.git","ssh_url":"git@github.com:tgaloppo/spark.git","clone_url":"https://github.com/tgaloppo/spark.git","svn_url":"https://github.com/tgaloppo/spark","homepage":null,"size":86932,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"7749dd6c36a182478b20f4636734c8db0b7ddb00","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-01-04T20:41:01Z","pushed_at":"2015-01-04T20:41:01Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":1086961,"stargazers_count":2474,"watchers_count":2474,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2196,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":289,"forks":2196,"open_issues":289,"watchers":2474,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/3871"},"html":{"href":"https://github.com/apache/spark/pull/3871"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/3871"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/3871/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/3871/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/3871/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/629d9d03e4bfd79410c8e1471e05986970022175"}}}}