Struct rand_simple::Weibull
source · pub struct Weibull { /* private fields */ }Expand description
Weibull Distribution
Example
let mut weibull = rand_simple::Weibull::new(1192u32);
assert_eq!(format!("{weibull}"), "Weibull(Shape parameter, Scale parameter) = Weibull(1, 1)");
// If you want to change the parameters of the random variable
let shape: f64 = 2f64;
let scale: f64 = 1.5f64;
let result: Result<(f64, f64), &str> = weibull.try_set_params(shape, scale);
assert_eq!(format!("{weibull}"), "Weibull(Shape parameter, Scale parameter) = Weibull(2, 1.5)");Implementations§
source§impl Weibull
impl Weibull
sourcepub fn new(_seed: u32) -> Self
pub fn new(_seed: u32) -> Self
Constructor for the Weibull random number generator.
_seed- Seed for the random number generator.
sourcepub fn sample(&mut self) -> f64
pub fn sample(&mut self) -> f64
Computes a random number. Returns a random number sampled from the Weibull distribution with the specified shape and scale parameters.
sourcepub fn try_set_params(
&mut self,
shape: f64,
scale: f64
) -> Result<(f64, f64), &str>
pub fn try_set_params( &mut self, shape: f64, scale: f64 ) -> Result<(f64, f64), &str>
Attempts to set the parameters of the probability variable.
shape- Shape parameter.scale- Scale parameter. Returns a Result containing a tuple (shape, scale) on success, or an error message if the parameters are invalid.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Weibull
impl Send for Weibull
impl Sync for Weibull
impl Unpin for Weibull
impl UnwindSafe for Weibull
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