{"action":"closed","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/14010","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/14010/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/14010/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/14010/events","html_url":"https://github.com/JuliaLang/julia/issues/14010","id":117054743,"number":14010,"title":"Correctness of the Ziggurat method","user":{"login":"jameslao","id":5279743,"avatar_url":"https://avatars.githubusercontent.com/u/5279743?v=3","gravatar_id":"","url":"https://api.github.com/users/jameslao","html_url":"https://github.com/jameslao","followers_url":"https://api.github.com/users/jameslao/followers","following_url":"https://api.github.com/users/jameslao/following{/other_user}","gists_url":"https://api.github.com/users/jameslao/gists{/gist_id}","starred_url":"https://api.github.com/users/jameslao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jameslao/subscriptions","organizations_url":"https://api.github.com/users/jameslao/orgs","repos_url":"https://api.github.com/users/jameslao/repos","events_url":"https://api.github.com/users/jameslao/events{/privacy}","received_events_url":"https://api.github.com/users/jameslao/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-16T05:36:27Z","updated_at":"2015-11-16T19:53:25Z","closed_at":"2015-11-16T19:53:25Z","body":"I'm recently studying the Ziggurat method and see that `julia/test/perf/kernel/ziggurat.jl` is directly ported [http://m.seehuhn.de/data/ziggurat/gauss.c](http://m.seehuhn.de/data/ziggurat/gauss.c). However, when looking at these numbers, starting from `const PARAM_R = 3.44428647676`, I find them not matching what I calculated. These valued are generated from [http://m.seehuhn.de/data/ziggurat/ziggurat.c](http://m.seehuhn.de/data/ziggurat/ziggurat.c)\r\n\r\nThe problem with this generated value is, in `ziggurat.c`, line 48, when it tries the r value, the formula to calculate the initial v value is \r\n\r\n`v = r*f(r) + exp(-0.5*r*r)/r;`\r\n\r\nThis is not what *v* should be... the second item on the right should be the integral from *r* to infinity, namely the erfc function.\r\n\r\nTo further support this claim, in [https://github.com/sarahr/QVMC/blob/master/zignor.c](https://github.com/sarahr/QVMC/blob/master/zignor.c), this improved method from Doornik has `R = 3.442619855899`. The code from the original paper [http://www.jstatsoft.org/article/downloadSuppFile/v005i08/rnorrexp.c](http://www.jstatsoft.org/article/downloadSuppFile/v005i08/rnorrexp.c) also gives `R=3.442620`. I verified with 1-CDF and this is the correct value (error to the order of 1e-12).\r\n\r\nSince this R value is wrong all the tables are wrong."}}