Skip to content

Poisson returns -1 for small lambda#1284

Merged
dhardy merged 2 commits intorust-random:masterfrom
tearne:poissonknuth
Feb 13, 2023
Merged

Poisson returns -1 for small lambda#1284
dhardy merged 2 commits intorust-random:masterfrom
tearne:poissonknuth

Conversation

@tearne
Copy link
Copy Markdown
Contributor

@tearne tearne commented Feb 10, 2023

Small lambda reveals the current implementation of Knuth's method fails, yielding an output of -1. It can be fixed with different starting values.

Copy link
Copy Markdown
Member

@dhardy dhardy left a comment

Choose a reason for hiding this comment

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

Aha, looks like the condition was tested too soon relative to Knuth's method (usually written do ... while condition).

@vks
Copy link
Copy Markdown
Contributor

vks commented Feb 12, 2023

Thanks! Could you please also add a bullet point to the CHANGELOG.md?

@tearne
Copy link
Copy Markdown
Contributor Author

tearne commented Feb 12, 2023

Sure. Done. Force-pushed since I had initially branched off 0.4.3

@dhardy dhardy merged commit f2e21db into rust-random:master Feb 13, 2023
@tearne tearne deleted the poissonknuth branch February 13, 2023 09:39
benjamin-lieser pushed a commit to benjamin-lieser/rand that referenced this pull request Feb 5, 2025
* Correct Knuth's method since not using do-while
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