Binomial: Faster sampling for n * p >= 10#740
Merged
dhardy merged 7 commits intorust-random:masterfrom Apr 1, 2019
Merged
Conversation
Contributor
Author
|
cc @geq1t |
Member
|
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. |
Member
|
Rebase please |
bf96f64 to
e5d8c2c
Compare
Contributor
Author
|
I rebased on master. |
Contributor
Author
|
Rebased again. This includes the fix for MIPS. |
Member
|
Ah, sorry, I'll try to get to reviewing this this week. |
dhardy
reviewed
Mar 22, 2019
Member
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.
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.
dhardy
approved these changes
Apr 1, 2019
vks
added a commit
to vks/rand
that referenced
this pull request
May 15, 2019
When moving the distribution from `rand` to `rand_distr`, the changes from rust-random#740 were missed. This commit adds those changes.
benjamin-lieser
pushed a commit
to benjamin-lieser/rand
that referenced
this pull request
Feb 5, 2025
When moving the distribution from `rand` to `rand_distr`, the changes from rust-random#740 were missed. This commit adds those changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before:
After:
This requires #735.