-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binomial: Faster sampling for n * p >= 10 #740
Conversation
cc @geq1t |
Great. I will hold off merging this until after #735. |
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. |
Rebase please |
bf96f64
to
e5d8c2c
Compare
I rebased on master. |
Rebased again. This includes the fix for MIPS. |
Ah, sorry, I'll try to get to reviewing this this week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
Before:
After:
This requires #735.