diff --git a/src/distribution/dirichlet.rs b/src/distribution/dirichlet.rs index 1cc19bee..87b6a332 100644 --- a/src/distribution/dirichlet.rs +++ b/src/distribution/dirichlet.rs @@ -428,6 +428,17 @@ mod tests { bad_create_case(vector![0.001, f64::INFINITY, 3756.0]); // moved to bad case as this is degenerate } + #[cfg(feature = "rand")] + #[test] + fn test_sample() { + use rand::distr::Distribution; + use rand::SeedableRng; + + test_almost(vector![1., 2.], 1., 1e-15, |dd| { + dd.sample(&mut rand::rngs::StdRng::seed_from_u64(0)).sum() + }); + } + #[test] fn test_mean() { let mean = |dd: Dirichlet<_>| dd.mean().unwrap();