Skip to content

Commit 2aa5c9b

Browse files
authored
Replaces the Poisson rejection method implementation (rust-random#1560)
- [x] Added a `CHANGELOG.md` entry # Summary As discussed in rust-random#1515, this PR replaces the implementation of `poisson::RejectionMethod` with a new algorithm based on the [paper ](https://dl.acm.org/doi/10.1145/355993.355997). # Motivation The new implementation offers improved performance and maintains better sampling distribution, especially for extreme values of lambda (> 1e9). # Details In terms of performance, here are the benchmarks I ran, with the current implementation as the baseline: ```text poisson/100 time: [45.5242 cycles 45.6734 cycles 45.8337 cycles] change: [-86.572% -86.507% -86.438%] (p = 0.00 < 0.05) Performance has improved. Found 5 outliers among 100 measurements (5.00%) 2 (2.00%) low mild 2 (2.00%) high mild 1 (1.00%) high severe poisson/variable time: [5494.6626 cycles 5508.2882 cycles 5523.2298 cycles] thrpt: [5523.2298 cycles/100 5508.2882 cycles/100 5494.6626 cycles/100] change: time: [-76.728% -76.573% -76.430%] (p = 0.00 < 0.05) thrpt: [+324.27% +326.85% +329.69%] Performance has improved. Found 5 outliers among 100 measurements (5.00%) 1 (1.00%) low mild 3 (3.00%) high mild 1 (1.00%) high severe ```
1 parent 0733a11 commit 2aa5c9b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/cdf.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@ fn hypergeometric() {
427427
fn poisson() {
428428
use rand_distr::Poisson;
429429
let parameters = [
430-
0.1, 1.0, 7.5,
431-
45.0, // 1e9, passed case but too slow
432-
// 1.844E+19, // fail case
430+
0.1, 1.0, 7.5, 15.0, 45.0, 98.0, 230.0, 4567.5,
431+
4.4541e7, // 1e10, //passed case but too slow
432+
// 1.844E+19, // fail case
433433
];
434434

435435
for (seed, lambda) in parameters.into_iter().enumerate() {

0 commit comments

Comments
 (0)