{"action":"created","comment":{"url":"https://api.github.com/repos/is0280fp/generative_models/pulls/comments/182974967","pull_request_review_id":113883970,"id":182974967,"diff_hunk":"@@ -0,0 +1,96 @@\n+# -*- coding: utf-8 -*-\n+\"\"\"\n+Created on Thu Mar 29 19:38:29 2018\n+\n+@author: yume\n+\"\"\"\n+\n+import numpy as np\n+import matplotlib.pyplot as plt\n+from operator import itemgetter\n+import mixture_distributions\n+\n+\n+def gaussian_paras(x):\n+    n = len(x)\n+    mean = x.sum() / n\n+    var = ((x - mean) ** 2).sum() / n\n+    std = var ** 0.5\n+    return (mean, var, std)\n+\n+\n+if __name__ == '__main__':\n+    sampler = mixture_distributions.MixtureOfGaussians()\n+    z, x = sampler(10000, complete_data=True)\n+    sampler.visualize(x)\n+    print(\"Distribution: \", sampler.get_name())\n+    print(\"Parameters: \", sampler.get_params())\n+\n+    K = len(np.unique(z))  # 3\n+    n = len(z)\n+    x_number = np.bincount(z)\n+    probabilities = [x_number/n]\n+\n+    print(\"K:\", K)\n+    print(\"p:\", probabilities)\n+\n+    x0_lst = []\n+    x1_lst = []\n+    x2_lst = []\n+    for i in np.arange(len(z)):\n+        if z[i] == 0:\n+            x0_lst.append([x[i]])\n+        elif z[i] == 1:\n+            x1_lst.append([x[i]])\n+        else:\n+            x2_lst.append([x[i]])\n+\n+    mean_lst = []\n+    var_lst = []\n+    std_lst = []\n+    x0_lst = np.array(x0_lst)\n+    x1_lst = np.array(x1_lst)\n+    x2_lst = np.array(x2_lst)\n+\n+    mean, var, std = gaussian_paras(x0_lst)\n+    mean_lst.append(mean)\n+    var_lst.append(var)\n+    std_lst.append(std)\n+\n+    mean, var, std = gaussian_paras(x1_lst)\n+    mean_lst.append(mean)\n+    var_lst.append(var)\n+    std_lst.append(std)\n+\n+    mean, var, std = gaussian_paras(x2_lst)\n+    mean_lst.append(mean)\n+    var_lst.append(var)\n+    std_lst.append(std)\n+\n+    y0_lst = []","path":"mixture_of_gaussians.py","position":70,"original_position":70,"commit_id":"f2f60c1489e49f84015d4f9dc76d490efc53119e","original_commit_id":"f2f60c1489e49f84015d4f9dc76d490efc53119e","user":{"login":"ronekko","id":142082,"avatar_url":"https://avatars1.githubusercontent.com/u/142082?v=4","gravatar_id":"","url":"https://api.github.com/users/ronekko","html_url":"https://github.com/ronekko","followers_url":"https://api.github.com/users/ronekko/followers","following_url":"https://api.github.com/users/ronekko/following{/other_user}","gists_url":"https://api.github.com/users/ronekko/gists{/gist_id}","starred_url":"https://api.github.com/users/ronekko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronekko/subscriptions","organizations_url":"https://api.github.com/users/ronekko/orgs","repos_url":"https://api.github.com/users/ronekko/repos","events_url":"https://api.github.com/users/ronekko/events{/privacy}","received_events_url":"https://api.github.com/users/ronekko/received_events","type":"User","site_admin":false},"body":"生成の仕方がちょっと間違ってますね．\r\n今回の生成モデルではzも新たにサンプリングする必要があります．\r\nそれなのに，zはデータセットのものを使ってしまってます．","created_at":"2018-04-20T08:08:13Z","updated_at":"2018-04-20T08:08:14Z","html_url":"https://github.com/is0280fp/generative_models/pull/5#discussion_r182974967","pull_request_url":"https://api.github.com/repos/is0280fp/generative_models/pulls/5","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/is0280fp/generative_models/pulls/comments/182974967"},"html":{"href":"https://github.com/is0280fp/generative_models/pull/5#discussion_r182974967"},"pull_request":{"href":"https://api.github.com/repos/is0280fp/generative_models/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/is0280fp/generative_models/pulls/5","id":182787312,"html_url":"https://github.com/is0280fp/generative_models/pull/5","diff_url":"https://github.com/is0280fp/generative_models/pull/5.diff","patch_url":"https://github.com/is0280fp/generative_models/pull/5.patch","issue_url":"https://api.github.com/repos/is0280fp/generative_models/issues/5","number":5,"state":"open","locked":false,"title":"混合ガウシアン分布(完全データ)の最尤推定","user":{"login":"is0280fp","id":12329235,"avatar_url":"https://avatars3.githubusercontent.com/u/12329235?v=4","gravatar_id":"","url":"https://api.github.com/users/is0280fp","html_url":"https://github.com/is0280fp","followers_url":"https://api.github.com/users/is0280fp/followers","following_url":"https://api.github.com/users/is0280fp/following{/other_user}","gists_url":"https://api.github.com/users/is0280fp/gists{/gist_id}","starred_url":"https://api.github.com/users/is0280fp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/is0280fp/subscriptions","organizations_url":"https://api.github.com/users/is0280fp/orgs","repos_url":"https://api.github.com/users/is0280fp/repos","events_url":"https://api.github.com/users/is0280fp/events{/privacy}","received_events_url":"https://api.github.com/users/is0280fp/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-04-19T14:04:20Z","updated_at":"2018-04-20T08:08:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1d34e80cdf740515111207bf946a73105a49f6ad","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/is0280fp/generative_models/pulls/5/commits","review_comments_url":"https://api.github.com/repos/is0280fp/generative_models/pulls/5/comments","review_comment_url":"https://api.github.com/repos/is0280fp/generative_models/pulls/comments{/number}","comments_url":"https://api.github.com/repos/is0280fp/generative_models/issues/5/comments","statuses_url":"https://api.github.com/repos/is0280fp/generative_models/statuses/f2f60c1489e49f84015d4f9dc76d490efc53119e","head":{"label":"is0280fp:mixture_of_gaussians","ref":"mixture_of_gaussians","sha":"f2f60c1489e49f84015d4f9dc76d490efc53119e","user":{"login":"is0280fp","id":12329235,"avatar_url":"https://avatars3.githubusercontent.com/u/12329235?v=4","gravatar_id":"","url":"https://api.github.com/users/is0280fp","html_url":"https://github.com/is0280fp","followers_url":"https://api.github.com/users/is0280fp/followers","following_url":"https://api.github.com/users/is0280fp/following{/other_user}","gists_url":"https://api.github.com/users/is0280fp/gists{/gist_id}","starred_url":"https://api.github.com/users/is0280fp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/is0280fp/subscriptions","organizations_url":"https://api.github.com/users/is0280fp/orgs","repos_url":"https://api.github.com/users/is0280fp/repos","events_url":"https://api.github.com/users/is0280fp/events{/privacy}","received_events_url":"https://api.github.com/users/is0280fp/received_events","type":"User","site_admin":false},"repo":{"id":129375114,"name":"generative_models","full_name":"is0280fp/generative_models","owner":{"login":"is0280fp","id":12329235,"avatar_url":"https://avatars3.githubusercontent.com/u/12329235?v=4","gravatar_id":"","url":"https://api.github.com/users/is0280fp","html_url":"https://github.com/is0280fp","followers_url":"https://api.github.com/users/is0280fp/followers","following_url":"https://api.github.com/users/is0280fp/following{/other_user}","gists_url":"https://api.github.com/users/is0280fp/gists{/gist_id}","starred_url":"https://api.github.com/users/is0280fp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/is0280fp/subscriptions","organizations_url":"https://api.github.com/users/is0280fp/orgs","repos_url":"https://api.github.com/users/is0280fp/repos","events_url":"https://api.github.com/users/is0280fp/events{/privacy}","received_events_url":"https://api.github.com/users/is0280fp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/is0280fp/generative_models","description":null,"fork":false,"url":"https://api.github.com/repos/is0280fp/generative_models","forks_url":"https://api.github.com/repos/is0280fp/generative_models/forks","keys_url":"https://api.github.com/repos/is0280fp/generative_models/keys{/key_id}","collaborators_url":"https://api.github.com/repos/is0280fp/generative_models/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/is0280fp/generative_models/teams","hooks_url":"https://api.github.com/repos/is0280fp/generative_models/hooks","issue_events_url":"https://api.github.com/repos/is0280fp/generative_models/issues/events{/number}","events_url":"https://api.github.com/repos/is0280fp/generative_models/events","assignees_url":"https://api.github.com/repos/is0280fp/generative_models/assignees{/user}","branches_url":"https://api.github.com/repos/is0280fp/generative_models/branches{/branch}","tags_url":"https://api.github.com/repos/is0280fp/generative_models/tags","blobs_url":"https://api.github.com/repos/is0280fp/generative_models/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/is0280fp/generative_models/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/is0280fp/generative_models/git/refs{/sha}","trees_url":"https://api.github.com/repos/is0280fp/generative_models/git/trees{/sha}","statuses_url":"https://api.github.com/repos/is0280fp/generative_models/statuses/{sha}","languages_url":"https://api.github.com/repos/is0280fp/generative_models/languages","stargazers_url":"https://api.github.com/repos/is0280fp/generative_models/stargazers","contributors_url":"https://api.github.com/repos/is0280fp/generative_models/contributors","subscribers_url":"https://api.github.com/repos/is0280fp/generative_models/subscribers","subscription_url":"https://api.github.com/repos/is0280fp/generative_models/subscription","commits_url":"https://api.github.com/repos/is0280fp/generative_models/commits{/sha}","git_commits_url":"https://api.github.com/repos/is0280fp/generative_models/git/commits{/sha}","comments_url":"https://api.github.com/repos/is0280fp/generative_models/comments{/number}","issue_comment_url":"https://api.github.com/repos/is0280fp/generative_models/issues/comments{/number}","contents_url":"https://api.github.com/repos/is0280fp/generative_models/contents/{+path}","compare_url":"https://api.github.com/repos/is0280fp/generative_models/compare/{base}...{head}","merges_url":"https://api.github.com/repos/is0280fp/generative_models/merges","archive_url":"https://api.github.com/repos/is0280fp/generative_models/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/is0280fp/generative_models/downloads","issues_url":"https://api.github.com/repos/is0280fp/generative_models/issues{/number}","pulls_url":"https://api.github.com/repos/is0280fp/generative_models/pulls{/number}","milestones_url":"https://api.github.com/repos/is0280fp/generative_models/milestones{/number}","notifications_url":"https://api.github.com/repos/is0280fp/generative_models/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/is0280fp/generative_models/labels{/name}","releases_url":"https://api.github.com/repos/is0280fp/generative_models/releases{/id}","deployments_url":"https://api.github.com/repos/is0280fp/generative_models/deployments","created_at":"2018-04-13T08:48:13Z","updated_at":"2018-04-20T07:17:55Z","pushed_at":"2018-04-20T07:50:48Z","git_url":"git://github.com/is0280fp/generative_models.git","ssh_url":"git@github.com:is0280fp/generative_models.git","clone_url":"https://github.com/is0280fp/generative_models.git","svn_url":"https://github.com/is0280fp/generative_models","homepage":null,"size":14,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"is0280fp:master","ref":"master","sha":"54d4d2f894f224c3ac14aa07bb07a127998a4b7b","user":{"login":"is0280fp","id":12329235,"avatar_url":"https://avatars3.githubusercontent.com/u/12329235?v=4","gravatar_id":"","url":"https://api.github.com/users/is0280fp","html_url":"https://github.com/is0280fp","followers_url":"https://api.github.com/users/is0280fp/followers","following_url":"https://api.github.com/users/is0280fp/following{/other_user}","gists_url":"https://api.github.com/users/is0280fp/gists{/gist_id}","starred_url":"https://api.github.com/users/is0280fp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/is0280fp/subscriptions","organizations_url":"https://api.github.com/users/is0280fp/orgs","repos_url":"https://api.github.com/users/is0280fp/repos","events_url":"https://api.github.com/users/is0280fp/events{/privacy}","received_events_url":"https://api.github.com/users/is0280fp/received_events","type":"User","site_admin":false},"repo":{"id":129375114,"name":"generative_models","full_name":"is0280fp/generative_models","owner":{"login":"is0280fp","id":12329235,"avatar_url":"https://avatars3.githubusercontent.com/u/12329235?v=4","gravatar_id":"","url":"https://api.github.com/users/is0280fp","html_url":"https://github.com/is0280fp","followers_url":"https://api.github.com/users/is0280fp/followers","following_url":"https://api.github.com/users/is0280fp/following{/other_user}","gists_url":"https://api.github.com/users/is0280fp/gists{/gist_id}","starred_url":"https://api.github.com/users/is0280fp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/is0280fp/subscriptions","organizations_url":"https://api.github.com/users/is0280fp/orgs","repos_url":"https://api.github.com/users/is0280fp/repos","events_url":"https://api.github.com/users/is0280fp/events{/privacy}","received_events_url":"https://api.github.com/users/is0280fp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/is0280fp/generative_models","description":null,"fork":false,"url":"https://api.github.com/repos/is0280fp/generative_models","forks_url":"https://api.github.com/repos/is0280fp/generative_models/forks","keys_url":"https://api.github.com/repos/is0280fp/generative_models/keys{/key_id}","collaborators_url":"https://api.github.com/repos/is0280fp/generative_models/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/is0280fp/generative_models/teams","hooks_url":"https://api.github.com/repos/is0280fp/generative_models/hooks","issue_events_url":"https://api.github.com/repos/is0280fp/generative_models/issues/events{/number}","events_url":"https://api.github.com/repos/is0280fp/generative_models/events","assignees_url":"https://api.github.com/repos/is0280fp/generative_models/assignees{/user}","branches_url":"https://api.github.com/repos/is0280fp/generative_models/branches{/branch}","tags_url":"https://api.github.com/repos/is0280fp/generative_models/tags","blobs_url":"https://api.github.com/repos/is0280fp/generative_models/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/is0280fp/generative_models/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/is0280fp/generative_models/git/refs{/sha}","trees_url":"https://api.github.com/repos/is0280fp/generative_models/git/trees{/sha}","statuses_url":"https://api.github.com/repos/is0280fp/generative_models/statuses/{sha}","languages_url":"https://api.github.com/repos/is0280fp/generative_models/languages","stargazers_url":"https://api.github.com/repos/is0280fp/generative_models/stargazers","contributors_url":"https://api.github.com/repos/is0280fp/generative_models/contributors","subscribers_url":"https://api.github.com/repos/is0280fp/generative_models/subscribers","subscription_url":"https://api.github.com/repos/is0280fp/generative_models/subscription","commits_url":"https://api.github.com/repos/is0280fp/generative_models/commits{/sha}","git_commits_url":"https://api.github.com/repos/is0280fp/generative_models/git/commits{/sha}","comments_url":"https://api.github.com/repos/is0280fp/generative_models/comments{/number}","issue_comment_url":"https://api.github.com/repos/is0280fp/generative_models/issues/comments{/number}","contents_url":"https://api.github.com/repos/is0280fp/generative_models/contents/{+path}","compare_url":"https://api.github.com/repos/is0280fp/generative_models/compare/{base}...{head}","merges_url":"https://api.github.com/repos/is0280fp/generative_models/merges","archive_url":"https://api.github.com/repos/is0280fp/generative_models/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/is0280fp/generative_models/downloads","issues_url":"https://api.github.com/repos/is0280fp/generative_models/issues{/number}","pulls_url":"https://api.github.com/repos/is0280fp/generative_models/pulls{/number}","milestones_url":"https://api.github.com/repos/is0280fp/generative_models/milestones{/number}","notifications_url":"https://api.github.com/repos/is0280fp/generative_models/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/is0280fp/generative_models/labels{/name}","releases_url":"https://api.github.com/repos/is0280fp/generative_models/releases{/id}","deployments_url":"https://api.github.com/repos/is0280fp/generative_models/deployments","created_at":"2018-04-13T08:48:13Z","updated_at":"2018-04-20T07:17:55Z","pushed_at":"2018-04-20T07:50:48Z","git_url":"git://github.com/is0280fp/generative_models.git","ssh_url":"git@github.com:is0280fp/generative_models.git","clone_url":"https://github.com/is0280fp/generative_models.git","svn_url":"https://github.com/is0280fp/generative_models","homepage":null,"size":14,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/is0280fp/generative_models/pulls/5"},"html":{"href":"https://github.com/is0280fp/generative_models/pull/5"},"issue":{"href":"https://api.github.com/repos/is0280fp/generative_models/issues/5"},"comments":{"href":"https://api.github.com/repos/is0280fp/generative_models/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/is0280fp/generative_models/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/is0280fp/generative_models/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/is0280fp/generative_models/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/is0280fp/generative_models/statuses/f2f60c1489e49f84015d4f9dc76d490efc53119e"}},"author_association":"OWNER"}}
{"actor":{"display_login":"ronekko"}}