{"action":"created","issue":{"url":"https://api.github.com/repos/mathnet/mathnet-numerics/issues/442","repository_url":"https://api.github.com/repos/mathnet/mathnet-numerics","labels_url":"https://api.github.com/repos/mathnet/mathnet-numerics/issues/442/labels{/name}","comments_url":"https://api.github.com/repos/mathnet/mathnet-numerics/issues/442/comments","events_url":"https://api.github.com/repos/mathnet/mathnet-numerics/issues/442/events","html_url":"https://github.com/mathnet/mathnet-numerics/issues/442","id":183972013,"number":442,"title":"Bug on Gamma Distribution","user":{"login":"arubiomoreno","id":2436692,"avatar_url":"https://avatars.githubusercontent.com/u/2436692?v=3","gravatar_id":"","url":"https://api.github.com/users/arubiomoreno","html_url":"https://github.com/arubiomoreno","followers_url":"https://api.github.com/users/arubiomoreno/followers","following_url":"https://api.github.com/users/arubiomoreno/following{/other_user}","gists_url":"https://api.github.com/users/arubiomoreno/gists{/gist_id}","starred_url":"https://api.github.com/users/arubiomoreno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arubiomoreno/subscriptions","organizations_url":"https://api.github.com/users/arubiomoreno/orgs","repos_url":"https://api.github.com/users/arubiomoreno/repos","events_url":"https://api.github.com/users/arubiomoreno/events{/privacy}","received_events_url":"https://api.github.com/users/arubiomoreno/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-19T14:07:34Z","updated_at":"2016-10-19T14:33:25Z","closed_at":null,"body":"Hello.\r\n\r\nThere is a problem with the Gamma distribution implementation.\r\nFailure test case:\r\n```\r\nGamma g = new Gamma(1082.2442991605726, 1.0750962053293897E-06);\r\nDouble a = g.InverseCumulativeDistribution(0.990); // Works\r\nDouble b = g.InverseCumulativeDistribution(0.9919); // Fails\r\nDouble c = g.InverseCumulativeDistribution(0.993); // Works\r\n```\r\nThe error is located on this while loop, where x becomes negative.\r\nFile name is Gamma.cs and function is `MathNet.Numerics.SpecialFunctions.GammaLowerRegularizedInv`\r\n```\r\nwhile (xUpper == big)            \r\n{                                          \r\n    x = (1 + d)*x;                         \r\n    y = 1 - GammaLowerRegularized(a, x);   \r\n    if (y < y0)                            \r\n    {                                      \r\n        xUpper = x;                        \r\n        yLower = y;                        \r\n        break;                             \r\n    }                                      \r\n                                           \r\n    d = d + d;                             \r\n}\r\n```\r\nI tried adding to the loop the condition `&& d > -1` and it looks like it is working, but I do not have any idea on what is being done there so please have a look at it."},"comment":{"url":"https://api.github.com/repos/mathnet/mathnet-numerics/issues/comments/254831171","html_url":"https://github.com/mathnet/mathnet-numerics/issues/442#issuecomment-254831171","issue_url":"https://api.github.com/repos/mathnet/mathnet-numerics/issues/442","id":254831171,"user":{"login":"arubiomoreno","id":2436692,"avatar_url":"https://avatars.githubusercontent.com/u/2436692?v=3","gravatar_id":"","url":"https://api.github.com/users/arubiomoreno","html_url":"https://github.com/arubiomoreno","followers_url":"https://api.github.com/users/arubiomoreno/followers","following_url":"https://api.github.com/users/arubiomoreno/following{/other_user}","gists_url":"https://api.github.com/users/arubiomoreno/gists{/gist_id}","starred_url":"https://api.github.com/users/arubiomoreno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arubiomoreno/subscriptions","organizations_url":"https://api.github.com/users/arubiomoreno/orgs","repos_url":"https://api.github.com/users/arubiomoreno/repos","events_url":"https://api.github.com/users/arubiomoreno/events{/privacy}","received_events_url":"https://api.github.com/users/arubiomoreno/received_events","type":"User","site_admin":false},"created_at":"2016-10-19T14:33:25Z","updated_at":"2016-10-19T14:33:25Z","body":"Also changing the inmediately previous for loop upper limit from 10 to 12 (without the while modification) seems to solve the bug for this specific case. It looks cleaner also."}}
{"actor":{"display_login":"arubiomoreno"}}