GitHub PullRequestEvent at 2014-11-26 00:36:12
Repository: QuantEcon.jl
Actor: spencerlyon2
Payload: {"action":"closed","number":23,"pull_request":{"url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/pulls/23","id":24916899,"html_url":"https://github.com/QuantEcon/QuantEcon.jl/pull/23","diff_url":"https://github.com/QuantEcon/QuantEcon.jl/pull/23.diff","patch_url":"https://github.com/QuantEcon/QuantEcon.jl/pull/23.patch","issue_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/issues/23","number":23,"state":"closed","locked":false,"title":"Implement the GTH algorithm","user":{"login":"oyamad","id":7353083,"avatar_url":"https://avatars.githubusercontent.com/u/7353083?v=3","gravatar_id":"","url":"https://api.github.com/users/oyamad","html_url":"https://github.com/oyamad","followers_url":"https://api.github.com/users/oyamad/followers","following_url":"https://api.github.com/users/oyamad/following{/other_user}","gists_url":"https://api.github.com/users/oyamad/gists{/gist_id}","starred_url":"https://api.github.com/users/oyamad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oyamad/subscriptions","organizations_url":"https://api.github.com/users/oyamad/orgs","repos_url":"https://api.github.com/users/oyamad/repos","events_url":"https://api.github.com/users/oyamad/events{/privacy}","received_events_url":"https://api.github.com/users/oyamad/received_events","type":"User","site_admin":false},"body":"This is to import [gth_solve.py](https://github.com/QuantEcon/QuantEcon.py/blob/master/quantecon/gth_solve.py) to the Julia part (I also imported the tests as well).\r\n(I have had a brief discussion with @ZacCranko on this matter.)\r\n\r\n1.\r\nThis is why I think `gth_solve` is necessary also for the Julia side:\r\n\r\nI guess that the source of the problem is the same as in NumPy and SciPy, but it seems the routine (probably `lufact`) from the Julia standard library loses precision for some inputs with very small float numbers.\r\n\r\nHere's an example:\r\n\r\n```julia\r\nfor i in 12:18\r\n    a = 1e-1 ^ i\r\n    P = [1-a a; a/2 1-a/2]\r\n    mc = MarkovChain(P)\r\n    print(\"a = 1e-\", i, \"\\n\")\r\n    print(mc_compute_stationary(mc), \"\\n\")\r\nend\r\n```\r\n\r\nThe output is:\r\n\r\n```julia\r\na = 1e-12\r\n[0.3333530884328846,0.6666469115671155]\r\na = 1e-13\r\n[0.33326424872384786,0.6667357512761523]\r\na = 1e-14\r\n[0.33315566870167473,0.6668443312983253]\r\na = 1e-15\r\n[0.3569592970777264,0.6430407029222737]\r\na = 1e-16\r\n[0.3105159921038858,0.6894840078961141]\r\na = 1e-17\r\n[0.0,1.0]\r\na = 1e-18\r\n[0.0,1.0]\r\n```\r\n\r\nThe correct answer is [1/3, 2/3] for any value of `a`.\r\n\r\nA problem occurs also for \"KMR Markov matrices\" with small epsilon.\r\n\r\nThe \"GTH\" algorithm is robust to this kind of inputs, as it does not involve subtraction. This is why I included \"gth_solve.py\" into the python side, and I believe this is also necessary for the julia side.\r\n\r\n2.\r\nI de-vectorized the python version following the general advice for Julia. Surprisingly, this de-vectorized version is 10x faster than the direct translation of the python version using array indexing for some random 1000x1000 matrices.\r\n\r\n3.\r\nDocstring is yet to be imported.\r\n\r\n4.\r\nI tried to follow a suggestion by @ZacCranko and manipulated the code, and then it appears the routine now returns an output with rational number elements for a matrix input with rational number elements:\r\n\r\n```julia\r\nP = [2//3 1//3; 1//4 3//4]\r\ngth_solve(P)\r\n```\r\n\r\nOutput:\r\n\r\n```julia\r\n2-element Array{Rational{Int64},1}:\r\n 3//7\r\n 4//7\r\n```\r\n\r\nBut I don't think I really understand what is going on..\r\n\r\n\r\nAnyway, this is effectively my first code in Julia, and definitely needs reviews by experienced Julia programmers... Thanks!\r\n","created_at":"2014-11-24T07:31:16Z","updated_at":"2014-11-26T00:36:12Z","closed_at":"2014-11-26T00:36:12Z","merged_at":"2014-11-26T00:36:12Z","merge_commit_sha":"2579b383e1a056f36c7ac0bf5fabc0d99e848d48","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/pulls/23/commits","review_comments_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/pulls/23/comments","review_comment_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/pulls/comments/{number}","comments_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/issues/23/comments","statuses_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/statuses/08a143ca86ff5070b14a4a822e753b2f32e6bf0e","head":{"label":"oyamad:gth_solve","ref":"gth_solve","sha":"08a143ca86ff5070b14a4a822e753b2f32e6bf0e","user":{"login":"oyamad","id":7353083,"avatar_url":"https://avatars.githubusercontent.com/u/7353083?v=3","gravatar_id":"","url":"https://api.github.com/users/oyamad","html_url":"https://github.com/oyamad","followers_url":"https://api.github.com/users/oyamad/followers","following_url":"https://api.github.com/users/oyamad/following{/other_user}","gists_url":"https://api.github.com/users/oyamad/gists{/gist_id}","starred_url":"https://api.github.com/users/oyamad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oyamad/subscriptions","organizations_url":"https://api.github.com/users/oyamad/orgs","repos_url":"https://api.github.com/users/oyamad/repos","events_url":"https://api.github.com/users/oyamad/events{/privacy}","received_events_url":"https://api.github.com/users/oyamad/received_events","type":"User","site_admin":false},"repo":{"id":27031805,"name":"QuantEcon.jl","full_name":"oyamad/QuantEcon.jl","owner":{"login":"oyamad","id":7353083,"avatar_url":"https://avatars.githubusercontent.com/u/7353083?v=3","gravatar_id":"","url":"https://api.github.com/users/oyamad","html_url":"https://github.com/oyamad","followers_url":"https://api.github.com/users/oyamad/followers","following_url":"https://api.github.com/users/oyamad/following{/other_user}","gists_url":"https://api.github.com/users/oyamad/gists{/gist_id}","starred_url":"https://api.github.com/users/oyamad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oyamad/subscriptions","organizations_url":"https://api.github.com/users/oyamad/orgs","repos_url":"https://api.github.com/users/oyamad/repos","events_url":"https://api.github.com/users/oyamad/events{/privacy}","received_events_url":"https://api.github.com/users/oyamad/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oyamad/QuantEcon.jl","description":"Julia implementation of QuantEcon routines","fork":true,"url":"https://api.github.com/repos/oyamad/QuantEcon.jl","forks_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/forks","keys_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/teams","hooks_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/hooks","issue_events_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/issues/events{/number}","events_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/events","assignees_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/assignees{/user}","branches_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/branches{/branch}","tags_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/tags","blobs_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/languages","stargazers_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/stargazers","contributors_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/contributors","subscribers_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/subscribers","subscription_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/subscription","commits_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/issues/comments/{number}","contents_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/contents/{+path}","compare_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/merges","archive_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/downloads","issues_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/issues{/number}","pulls_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/labels{/name}","releases_url":"https://api.github.com/repos/oyamad/QuantEcon.jl/releases{/id}","created_at":"2014-11-23T12:33:08Z","updated_at":"2014-11-23T12:33:08Z","pushed_at":"2014-11-25T06:52:36Z","git_url":"git://github.com/oyamad/QuantEcon.jl.git","ssh_url":"git@github.com:oyamad/QuantEcon.jl.git","clone_url":"https://github.com/oyamad/QuantEcon.jl.git","svn_url":"https://github.com/oyamad/QuantEcon.jl","homepage":null,"size":20625,"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":"QuantEcon:master","ref":"master","sha":"7a61edc96b07058885b8e4dc039c4f15120c11bb","user":{"login":"QuantEcon","id":8703060,"avatar_url":"https://avatars.githubusercontent.com/u/8703060?v=3","gravatar_id":"","url":"https://api.github.com/users/QuantEcon","html_url":"https://github.com/QuantEcon","followers_url":"https://api.github.com/users/QuantEcon/followers","following_url":"https://api.github.com/users/QuantEcon/following{/other_user}","gists_url":"https://api.github.com/users/QuantEcon/gists{/gist_id}","starred_url":"https://api.github.com/users/QuantEcon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuantEcon/subscriptions","organizations_url":"https://api.github.com/users/QuantEcon/orgs","repos_url":"https://api.github.com/users/QuantEcon/repos","events_url":"https://api.github.com/users/QuantEcon/events{/privacy}","received_events_url":"https://api.github.com/users/QuantEcon/received_events","type":"Organization","site_admin":false},"repo":{"id":21705573,"name":"QuantEcon.jl","full_name":"QuantEcon/QuantEcon.jl","owner":{"login":"QuantEcon","id":8703060,"avatar_url":"https://avatars.githubusercontent.com/u/8703060?v=3","gravatar_id":"","url":"https://api.github.com/users/QuantEcon","html_url":"https://github.com/QuantEcon","followers_url":"https://api.github.com/users/QuantEcon/followers","following_url":"https://api.github.com/users/QuantEcon/following{/other_user}","gists_url":"https://api.github.com/users/QuantEcon/gists{/gist_id}","starred_url":"https://api.github.com/users/QuantEcon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuantEcon/subscriptions","organizations_url":"https://api.github.com/users/QuantEcon/orgs","repos_url":"https://api.github.com/users/QuantEcon/repos","events_url":"https://api.github.com/users/QuantEcon/events{/privacy}","received_events_url":"https://api.github.com/users/QuantEcon/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/QuantEcon/QuantEcon.jl","description":"Julia implementation of QuantEcon routines","fork":false,"url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl","forks_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/forks","keys_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/teams","hooks_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/hooks","issue_events_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/issues/events{/number}","events_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/events","assignees_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/assignees{/user}","branches_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/branches{/branch}","tags_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/tags","blobs_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/languages","stargazers_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/stargazers","contributors_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/contributors","subscribers_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/subscribers","subscription_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/subscription","commits_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/issues/comments/{number}","contents_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/contents/{+path}","compare_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/merges","archive_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/downloads","issues_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/issues{/number}","pulls_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/labels{/name}","releases_url":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/releases{/id}","created_at":"2014-07-10T18:30:31Z","updated_at":"2014-11-24T18:46:31Z","pushed_at":"2014-11-26T00:36:12Z","git_url":"git://github.com/QuantEcon/QuantEcon.jl.git","ssh_url":"git@github.com:QuantEcon/QuantEcon.jl.git","clone_url":"https://github.com/QuantEcon/QuantEcon.jl.git","svn_url":"https://github.com/QuantEcon/QuantEcon.jl","homepage":null,"size":20625,"stargazers_count":14,"watchers_count":14,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":6,"forks":11,"open_issues":6,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/pulls/23"},"html":{"href":"https://github.com/QuantEcon/QuantEcon.jl/pull/23"},"issue":{"href":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/issues/23"},"comments":{"href":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/QuantEcon/QuantEcon.jl/statuses/08a143ca86ff5070b14a4a822e753b2f32e6bf0e"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"spencerlyon2","id":1001948,"avatar_url":"https://avatars.githubusercontent.com/u/1001948?v=3","gravatar_id":"","url":"https://api.github.com/users/spencerlyon2","html_url":"https://github.com/spencerlyon2","followers_url":"https://api.github.com/users/spencerlyon2/followers","following_url":"https://api.github.com/users/spencerlyon2/following{/other_user}","gists_url":"https://api.github.com/users/spencerlyon2/gists{/gist_id}","starred_url":"https://api.github.com/users/spencerlyon2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spencerlyon2/subscriptions","organizations_url":"https://api.github.com/users/spencerlyon2/orgs","repos_url":"https://api.github.com/users/spencerlyon2/repos","events_url":"https://api.github.com/users/spencerlyon2/events{/privacy}","received_events_url":"https://api.github.com/users/spencerlyon2/received_events","type":"User","site_admin":false},"comments":10,"review_comments":14,"commits":12,"additions":151,"deletions":2,"changed_files":4}}