Struct rand::distributions::binomial::Binomial
[−]
[src]
pub struct Binomial { /* fields omitted */ }
The binomial distribution Binomial(n, p)
.
This distribution has density function:
f(k) = n!/(k! (n-k)!) p^k (1-p)^(n-k)
for k >= 0
.
Example
use rand::distributions::{Binomial, Distribution}; let bin = Binomial::new(20, 0.3); let v = bin.sample(&mut rand::thread_rng()); println!("{} is from a binomial distribution", v);
Methods
impl Binomial
[src]
pub fn new(n: u64, p: f64) -> Binomial
[src]
Construct a new Binomial
with the given shape parameters
n
, p
. Panics if p <= 0
or p >= 1
.
Trait Implementations
impl Clone for Binomial
[src]
fn clone(&self) -> Binomial
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Copy for Binomial
[src]
impl Debug for Binomial
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more