{"action":"created","issue":{"url":"https://api.github.com/repos/PandaPhysics/PandaTree/issues/109","repository_url":"https://api.github.com/repos/PandaPhysics/PandaTree","labels_url":"https://api.github.com/repos/PandaPhysics/PandaTree/issues/109/labels{/name}","comments_url":"https://api.github.com/repos/PandaPhysics/PandaTree/issues/109/comments","events_url":"https://api.github.com/repos/PandaPhysics/PandaTree/issues/109/events","html_url":"https://github.com/PandaPhysics/PandaTree/pull/109","id":302045143,"number":109,"title":"Repeatable RNG","user":{"login":"sidnarayanan","id":8095275,"avatar_url":"https://avatars0.githubusercontent.com/u/8095275?v=4","gravatar_id":"","url":"https://api.github.com/users/sidnarayanan","html_url":"https://github.com/sidnarayanan","followers_url":"https://api.github.com/users/sidnarayanan/followers","following_url":"https://api.github.com/users/sidnarayanan/following{/other_user}","gists_url":"https://api.github.com/users/sidnarayanan/gists{/gist_id}","starred_url":"https://api.github.com/users/sidnarayanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidnarayanan/subscriptions","organizations_url":"https://api.github.com/users/sidnarayanan/orgs","repos_url":"https://api.github.com/users/sidnarayanan/repos","events_url":"https://api.github.com/users/sidnarayanan/events{/privacy}","received_events_url":"https://api.github.com/users/sidnarayanan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-03-04T00:28:51Z","updated_at":"2018-03-09T18:41:10Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/PandaPhysics/PandaTree/pulls/109","html_url":"https://github.com/PandaPhysics/PandaTree/pull/109","diff_url":"https://github.com/PandaPhysics/PandaTree/pull/109.diff","patch_url":"https://github.com/PandaPhysics/PandaTree/pull/109.patch"},"body":"Class that generates a fixed number of repeatable random numbers. Various simple PDFs are implemented. Many uniform->P(x) transformations are implemented best by various sampling techniques, which kind of defeats the point of this, so I only implemented Poisson in this fashion. \r\n\r\nHere's a little test suite:\r\n\r\n```C++\r\n#include \"PandaTree/Utils/interface/RRNG.h\"\r\n\r\n#include <iostream>\r\n\r\nusing namespace std;\r\n\r\nint\r\nmain(int argc, char const* argv[])\r\n{\r\n  RRNG r(1234, 20);\r\n\r\n  r.generate();\r\n  int idx = 0;\r\n  cout << \"U[0] = \" << r.uniform(idx) << endl;\r\n  cout << \"U[0] = \" << r.uniform() << endl;\r\n  cout << \"U[1] = \" << r.uniform() << endl;\r\n  cout << \"N[2] = \" << r.normal() << endl;\r\n  double x,y; r.normal(x,y);\r\n  cout << \"N[4,5] = \" << x << \" \"  << y << endl;\r\n  cout << \"L[5] = \" << r.landau(1, 1) << endl;\r\n\r\n  idx = 6;\r\n  unsigned N = r.poisson(5, idx);\r\n  cout << \"Poisson(5) = \" << N << endl;\r\n  cout << \"Took \" << idx - 6 << \" calls\" << endl;\r\n\r\n  cout << \"Poisson(15) = \" << r.poisson(15) << endl;\r\n  cout << \"Poisson(15) = \" << r.poisson(15) << endl;\r\n  cout << \"Poisson(15) = \" << r.poisson(15) << endl;\r\n  cout << \"Poisson(15) = \" << r.poisson(15) << endl;\r\n\r\n  idx = 100;\r\n  r.uniform(idx);\r\n\r\n  return 0;\r\n}\r\n```\r\n\r\nwhich prints (with `RRNG_DEBUG` on):\r\n```\r\nU[0] = 0.357817\r\nU[0] = 0.357817\r\nU[1] = 0.0129075\r\nN[2] = -1.1717\r\nN[4,5] = -0.425174 0.761835\r\nL[5] = 4.7379\r\nPoisson(5) = 6\r\nTook 6 calls\r\nPoisson(15) = 9\r\nRRNG::_requestNumber forced to re-generate numbers because we ran out!\r\nPoisson(15) = 21\r\nRRNG::_requestNumber forced to re-generate numbers because we ran out!\r\nPoisson(15) = 19\r\nRRNG::_requestNumber forced to re-generate numbers because we ran out!\r\nPoisson(15) = 17\r\nterminate called after throwing an instance of 'std::out_of_range'\r\n  what():  RRNG::_requestNumber accessing RN 100/20\r\nAborted\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/PandaPhysics/PandaTree/issues/comments/371907656","html_url":"https://github.com/PandaPhysics/PandaTree/pull/109#issuecomment-371907656","issue_url":"https://api.github.com/repos/PandaPhysics/PandaTree/issues/109","id":371907656,"user":{"login":"sidnarayanan","id":8095275,"avatar_url":"https://avatars0.githubusercontent.com/u/8095275?v=4","gravatar_id":"","url":"https://api.github.com/users/sidnarayanan","html_url":"https://github.com/sidnarayanan","followers_url":"https://api.github.com/users/sidnarayanan/followers","following_url":"https://api.github.com/users/sidnarayanan/following{/other_user}","gists_url":"https://api.github.com/users/sidnarayanan/gists{/gist_id}","starred_url":"https://api.github.com/users/sidnarayanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidnarayanan/subscriptions","organizations_url":"https://api.github.com/users/sidnarayanan/orgs","repos_url":"https://api.github.com/users/sidnarayanan/repos","events_url":"https://api.github.com/users/sidnarayanan/events{/privacy}","received_events_url":"https://api.github.com/users/sidnarayanan/received_events","type":"User","site_admin":false},"created_at":"2018-03-09T18:41:10Z","updated_at":"2018-03-09T18:41:10Z","author_association":"COLLABORATOR","body":"If there are no objections, I'll merge this this weekend. "}}
{"actor":{"display_login":"sidnarayanan"}}