Uh oh!
There was an error while loading. Please reload this page.
Binomial: Faster sampling for n * p >= 10 - #740
Conversation
vks
commented
Feb 21, 2019
cc @geq1t |
dhardy
commented
Feb 22, 2019
Great. I will hold off merging this until after #735. |
geq1t
commented
Feb 26, 2019
I don't really have a say in this, but from what I've seen BTPE is a very fast algorithm for binomial sampling, so implementing it would almost certainly be a win. I'll see if I can get a copy of the paper to compare against. |
dhardy
commented
Feb 27, 2019
Rebase please |
vks
commented
Feb 28, 2019
I rebased on master. |
vks
commented
Mar 13, 2019
Rebased again. This includes the fix for MIPS. |
dhardy
commented
Mar 14, 2019
Ah, sorry, I'll try to get to reviewing this this week. |
There was a problem hiding this comment.
The implementation appears to correspond to the algorithm in the K&S paper except where mentioned (apparently an error in the paper).
Why do you think some parts of the algorithm should be carried out with integers? It seems to me better to stick with floats until the result is ready.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This should be more efficient than our previous algorithm, see [1]. The implementation is close to the algorithm as specified in the paper, where many goto statements are used. It can still be refactored to be more readable. [1] Voratas Kachitvichyanukul and Bruce W. Schmeiser. 1988. Binomial random variate generation. Commun. ACM 31, 2 (February 1988), 216-222. http://dx.doi.org/10.1145/42372.42381
This was noted by the GSL implementors. The new signs were confirmed by one of the authors publishing the original algorithm.
When moving the distribution from `rand` to `rand_distr`, the changes from rust-random#740 were missed. This commit adds those changes.
When moving the distribution from `rand` to `rand_distr`, the changes from rust-random#740 were missed. This commit adds those changes.
Before:
After:
This requires #735.