From da0e67acfa099f7a342fe48c9fc2d68c5db02fb7 Mon Sep 17 00:00:00 2001 From: k88hudson Date: Wed, 29 Apr 2026 20:53:00 -0400 Subject: [PATCH] Change Poisson algorithm threshold to >=10 per Ahrens-Dieter paper --- CHANGELOG.md | 1 + src/poisson.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8e3044..e34d32e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixes - Avoid returning negative values in `InverseGaussian::sample`; this is a Value-breaking change ([#56]) - Fix Zipf returning values larger than `n` in rare cases ([#57]) +- Changed threshold for Ahrens-Dieter PD algorithm to >=10, matching the suggested value in the original 1982 paper ## [0.6.0] — 2026-02-10 - Bump to MSRV 1.85.0 and Edition 2024 in line with `rand` ([#28]) diff --git a/src/poisson.rs b/src/poisson.rs index 69dd655..041a4c1 100644 --- a/src/poisson.rs +++ b/src/poisson.rs @@ -161,7 +161,9 @@ where } // Use the Knuth method only for low expected values - let method = if lambda < F::from(12.0).unwrap() { + // Per Ahrens-Dieter, the rejection sampling algorithm is + // only designed for values >= 10 + let method = if lambda < F::from(10.0).unwrap() { Method::Knuth(KnuthMethod::new(lambda)) } else { if lambda > F::from(Self::MAX_LAMBDA).unwrap() {