Change Poisson algorithm threshold to >=10 per Ahrens-Dieter paper#55
Change Poisson algorithm threshold to >=10 per Ahrens-Dieter paper#55k88hudson wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Thank you. I've read the paper and confirm that the new threshold is still appropriate. The discrepancy was introduced in rust-random/rand@e06370c, which replaced a different sampling method, but forgot to adjust the constant used to choose the algorithm.
(Note: unlike the case of Julia, this PR is not a correctness fix, because Ahrens-Dieter previously was only used on the slightly narrower range of lambda in [12, infinity).)
Edit: hold on, I should benchmark this, to be sure. Knuth's method at lambda=10 makes ~10 float samples in expectation so I don't expect it to be faster, but maybe.... Edit 2: Ahrens-Dieter is about 40% faster than Knuth at lambda=11 on modern hardware, using a fast RNG.
46319e6 to
da0e67a
Compare
|
Rebased on latest |
CHANGELOG.mdentryI am not sure why
12.0was originally chosen, but the threshold recommended by the original 1982 paper ismu>=10so this would be an improvement for values 10–12. The algorithm would be faster for even lower values, but there are features (such as the hat function, defined in equation 24) that are specifically designed only to work down tomu = 10; the authors suggest this is the case and if you take a look at my comment here JuliaStats/Distributions.jl#2060, you can see that using lower values does indeed introduce bias.