Skip to content

Commit da0e67a

Browse files
committed
Change Poisson algorithm threshold to >=10 per Ahrens-Dieter paper
1 parent c49a9ea commit da0e67a

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
### Fixes
1313
- Avoid returning negative values in `InverseGaussian::sample`; this is a Value-breaking change ([#56])
1414
- Fix Zipf returning values larger than `n` in rare cases ([#57])
15+
- Changed threshold for Ahrens-Dieter PD algorithm to >=10, matching the suggested value in the original 1982 paper
1516

1617
## [0.6.0] — 2026-02-10
1718
- Bump to MSRV 1.85.0 and Edition 2024 in line with `rand` ([#28])

src/poisson.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ where
161161
}
162162

163163
// Use the Knuth method only for low expected values
164-
let method = if lambda < F::from(12.0).unwrap() {
164+
// Per Ahrens-Dieter, the rejection sampling algorithm is
165+
// only designed for values >= 10
166+
let method = if lambda < F::from(10.0).unwrap() {
165167
Method::Knuth(KnuthMethod::new(lambda))
166168
} else {
167169
if lambda > F::from(Self::MAX_LAMBDA).unwrap() {

0 commit comments

Comments
 (0)