pub struct Binomial<T> { /* private fields */ }Expand description
Binomial distribution B(n, p).
P(X = k) = C(n,k) p^k (1−p)^{n−k} for k = 0, …, n.
§Example
use numeris::stats::{Binomial, DiscreteDistribution};
let b = Binomial::new(10, 0.5_f64).unwrap();
assert!((b.mean() - 5.0).abs() < 1e-14);
assert!((b.variance() - 2.5).abs() < 1e-14);Implementations§
Source§impl<T: FloatScalar> Binomial<T>
impl<T: FloatScalar> Binomial<T>
Sourcepub fn new(n: u64, p: T) -> Result<Self, StatsError>
pub fn new(n: u64, p: T) -> Result<Self, StatsError>
Create a binomial distribution with n trials and success probability p.
Requires 0 ≤ p ≤ 1.
Trait Implementations§
Source§impl<T: FloatScalar> DiscreteDistribution<T> for Binomial<T>
impl<T: FloatScalar> DiscreteDistribution<T> for Binomial<T>
impl<T: Copy> Copy for Binomial<T>
Auto Trait Implementations§
impl<T> Freeze for Binomial<T>where
T: Freeze,
impl<T> RefUnwindSafe for Binomial<T>where
T: RefUnwindSafe,
impl<T> Send for Binomial<T>where
T: Send,
impl<T> Sync for Binomial<T>where
T: Sync,
impl<T> Unpin for Binomial<T>where
T: Unpin,
impl<T> UnsafeUnpin for Binomial<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Binomial<T>where
T: UnwindSafe,
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