lib_jsl_random/distributions/exponential.rs
1use crate::uniform_generator::UniformGenerator;
2
3/// An exponential sample with **rate** `lambda` (mean `1/λ`) by inversion, `−ln(1 − u)/λ`: the
4/// waiting time between events of a Poisson process.
5pub fn exponential_distribution<U>(uniform_generator: &mut U, lambda: f64) -> f64
6where
7 U: UniformGenerator,
8{
9 let uniform_sample: f64 = uniform_generator.next_f64();
10 -(1.0 - uniform_sample).ln() / lambda
11}