diff --git a/src/distribution/gumbel.rs b/src/distribution/gumbel.rs index d476ae27..b79e60aa 100644 --- a/src/distribution/gumbel.rs +++ b/src/distribution/gumbel.rs @@ -118,7 +118,7 @@ impl core::fmt::Display for Gumbel { impl ::rand::distr::Distribution for Gumbel { fn sample(&self, r: &mut R) -> f64 { let x = ::rand::RngExt::random::(r); - self.location - self.scale * ((-x).ln()).ln() + self.location - self.scale * (-x.ln()).ln() } } @@ -356,6 +356,19 @@ mod tests { create_ok(0.0, f64::INFINITY); } + #[test] + #[cfg(feature = "rand")] + fn test_sample() { + use rand::{distr::Distribution as _, rngs::StdRng, SeedableRng}; + + let mut rng = StdRng::seed_from_u64(437); + let n = create_ok(0.0, 1.0); + for _ in 0..20 { + let s = n.sample(&mut rng); + assert!(s.is_finite(), "sample was {s}"); + } + } + #[test] fn test_bad_create() { let invalid = [