Struct rand_simple::Exponential
source · pub struct Exponential { /* private fields */ }Expand description
Exponential Distribution
Example
let mut exponential = rand_simple::Exponential::new(1192_u32);
// Ensure that the distribution's representation includes the scale parameter
assert_eq!(format!("{exponential}"), "Exp(Scale parameter) = Exp(1)");
// Generate a random number following the Exponential distribution with the initial scale parameter
println!("Returns a random number -> {}", exponential.sample());
// Modify the distribution's scale parameter
let scale: f64 = 1.5_f64;
// Generate a random number following the modified Exponential distribution with scale parameter θ
let result: Result<f64, &str> = exponential.try_set_params(scale);
// Ensure that the distribution's representation includes the scale parameter
assert_eq!(format!("{exponential}"), "Exp(Scale parameter) = Exp(1.5)");
// Generate a random number following the Exponential distribution with the updated scale parameter
println!("Returns a random number -> {}", exponential.sample());Implementations§
source§impl Exponential
impl Exponential
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Exponential
impl Send for Exponential
impl Sync for Exponential
impl Unpin for Exponential
impl UnwindSafe for Exponential
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more