pub struct Beta { /* private fields */ }Expand description
Beta Distribution
§Example
// Create a new Beta distribution with specified random seeds
let mut beta = rand_simple::Beta::new([1192u32, 765u32, 1543u32, 2003u32, 1867u32, 1688u32]);
// Check the initial state
assert_eq!(format!("{beta}"), "Beta(Shape parameter α, Shape parameter β) = Beta(1, 1)");
// Generate a random number
println!("Returns a random number -> {}", beta.sample());
// Change the parameters of the probability variable
let shape_alpha: f64 = 2f64;
let shape_beta: f64 = 1.5f64;
let result: Result<(f64, f64), &str> = beta.try_set_params(shape_alpha, shape_beta);
// Check the updated state
assert_eq!(format!("{beta}"), "Beta(Shape parameter α, Shape parameter β) = Beta(2, 1.5)");
// Generate another random number
println!("Returns a random number -> {}", beta.sample());Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Beta
impl RefUnwindSafe for Beta
impl Send for Beta
impl Sync for Beta
impl Unpin for Beta
impl UnwindSafe for Beta
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