rust-random / rand

A Rust library for random number generation.
https://crates.io/crates/rand
Other
1.67k stars 431 forks source link

Poisson distribution returns -1.0 for very small values of lambda #1428

Closed thomasalcock closed 7 months ago

thomasalcock commented 7 months ago

With rand_distr = "0.4.3" and rand = "0.8.5" I was able to sample -1.0 by providing small enough values of lambda.

use rand_distr::{Distribution,Poisson};
use rand::thread_rng;

fn main() {

    let poisson_dist: Poisson<f32> = Poisson::new(0.0000000002).unwrap();
    println!("{:?}", poisson_dist.sample(&mut thread_rng()));

    let poisson_dist: Poisson<f64> = Poisson::new(0.0000000000000000002).unwrap();
    println!("{:?}", poisson_dist.sample(&mut thread_rng()));

}
dhardy commented 7 months ago

I can reproduce the bug with the versions listed, but not with the latest alpha releases.

vks commented 7 months ago

For reference, this was fixed with #1284.

Am Mi., 10. Apr. 2024 um 17:44 Uhr schrieb Diggory Hardy < @.***>:

Closed #1428 https://github.com/rust-random/rand/issues/1428 as completed.

— Reply to this email directly, view it on GitHub https://github.com/rust-random/rand/issues/1428#event-12424437858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAIFNAMY2F2A3V75MJRCE3Y4VM6RAVCNFSM6AAAAABFTM7QCKVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSGQZDINBTG44DKOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>