Struct rand_simple::Bernoulli
source · pub struct Bernoulli { /* private fields */ }Expand description
ベルヌーイ分布を計算する構造体
使用例 1 (new関数)
use rand_simple::Bernoulli;
let bernoulli = Bernoulli::new(1192u32);
let next = bernoulli.sample(0.5f64); // 発生確率 0.5の事象が生じたか(1)、否か(0)
println!("乱数: {}", next); // 0u32使用例 2 (マクロ・引数有り)
use rand_simple::create_bernoulli;
let bernoulli = create_bernoulli!(1192u32);
let next = bernoulli.sample(0.5f64); // 発生確率 0.5の事象が生じたか(1)、否か(0)
println!("乱数: {}", next); // 0u32使用例 3 (マクロ・引数無し)
use rand_simple::create_bernoulli;
let bernoulli = create_bernoulli!();
let next = bernoulli.sample(0.5f64); // 発生確率 0.5の事象が生じたか(1)、否か(0)
println!("乱数: {}", next); // 値不明Implementations§
Auto Trait Implementations§
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