pub struct Bernoulli { /* private fields */ }Expand description
Bernoulli Distribution
§Example Usage
let mut bernoulli = rand_simple::Bernoulli::new(1192u32);
// Default parameters
assert_eq!(format!("{bernoulli}"), "Bernoulli(Probability) = Bernoulli(0.5)");
println!("Does the event occur (1) or not (0) with a probability θ = 0.5? -> {}", bernoulli.sample());
// Updating the probability parameter
let probability: f64 = 0.8f64;
let result: Result<f64, &str> = bernoulli.try_set_params(probability);
assert_eq!(format!("{bernoulli}"), "Bernoulli(Probability) = Bernoulli(0.8)");
println!("Does the event occur (1) or not (0) with a probability θ = {}? -> {}", probability, bernoulli.sample());Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Bernoulli
impl RefUnwindSafe for Bernoulli
impl Send for Bernoulli
impl Sync for Bernoulli
impl Unpin for Bernoulli
impl UnwindSafe for Bernoulli
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