Skip to content
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

Poisson: split Knuth/Rejection methods #1493

Merged
merged 10 commits into from
Sep 23, 2024
Merged

Conversation

dhardy
Copy link
Member

@dhardy dhardy commented Sep 13, 2024

Summary

Use an enum over Poisson implementations

Motivation

#1484 uses the Poisson method internally, but only for small expected values.
@benjamin-lieser please merge this PR into yours and use poisson::KnuthMethod instead of Poisson.

Copy link
Member

@MichaelOwenDyer MichaelOwenDyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the thought behind the change, it doesn't make sense to decide which method to use every single time a Poisson distribution is sampled. Using an enum is cleaner. I have some thoughts on the details.
I can't comment too well on the benchmarking code, as I am unfamiliar with criterion and don't understand the reasons for many of the changes. I'm gonna go learn about Criterion now 🤠

rand_distr/src/lib.rs Show resolved Hide resolved
rand_distr/src/poisson.rs Outdated Show resolved Hide resolved
rand_distr/src/poisson.rs Outdated Show resolved Hide resolved
@MichaelOwenDyer
Copy link
Member

MichaelOwenDyer commented Sep 18, 2024

changes.patch
Here's a patch file of my suggestions.
Edit: Also added a constructor for RejectionMethod

@MichaelOwenDyer
Copy link
Member

Great, looks good to me now haha 😄 Unless you want to also add the getter for lamdba I'd say this is ready to go!

@dhardy dhardy merged commit f263820 into rust-random:master Sep 23, 2024
15 checks passed
benjamin-lieser pushed a commit to benjamin-lieser/rand that referenced this pull request Sep 25, 2024
@dhardy dhardy deleted the poisson-enum branch October 16, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants