Struct probability::prelude::Binomial [] [src]

pub struct Binomial {
    // some fields omitted
}

A binomial distribution.

Methods

impl Binomial
[src]

fn new(n: usize, p: f64) -> Binomial

Create a binomial distribution with n trails and success probability p.

It should hold that p >= 0 and p <= 1.

fn with_failure(n: usize, q: f64) -> Binomial

Create a binomial distribution with n trails and failure probability q.

It should hold that if q >= 0 or q <= 1. This constructor is preferable when q is very small.

fn n(&self) -> usize

Return the number of trials.

fn p(&self) -> f64

Return the success probability.

fn q(&self) -> f64

Return the failure probability.

Trait Implementations

impl Copy for Binomial
[src]

impl Clone for Binomial
[src]

fn clone(&self) -> Binomial

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl Distribution for Binomial
[src]

type Value = usize

The type of outcomes.

fn cdf(&self, x: f64) -> f64

Compute the cumulative distribution function.

The implementation is based on the incomplete beta function.

impl Discrete for Binomial
[src]

fn pmf(&self, x: usize) -> f64

Compute the probability mass function.

For large n, a saddle-point expansion is used for more accurate computation.

References

  1. C. Loader, “Fast and Accurate Computation of Binomial Probabilities,” 2000.

impl Entropy for Binomial
[src]

fn entropy(&self) -> f64

Compute the differential entropy. Read more

impl Inverse for Binomial
[src]

fn inv_cdf(&self, p: f64) -> usize

Compute the inverse of the cumulative distribution function.

For small n, a simple summation is utilized. For large n and large variances, a normal asymptotic approximation is used. Otherwise, the Newton method is employed.

References

  1. S. Moorhead, “Efficient evaluation of the inverse binomial cumulative distribution function where the number of trials is large,” Oxford University, 2013.

impl Kurtosis for Binomial
[src]

fn kurtosis(&self) -> f64

Compute the excess kurtosis.

impl Mean for Binomial
[src]

fn mean(&self) -> f64

Compute the expected value.

impl Median for Binomial
[src]

fn median(&self) -> f64

Compute the median.

impl Modes for Binomial
[src]

fn modes(&self) -> Vec<usize>

Compute the modes.

impl Sample for Binomial
[src]

fn sample<S>(&self, source: &mut S) -> usize where S: Source

Draw a sample.

impl Skewness for Binomial
[src]

fn skewness(&self) -> f64

Compute the skewness.

impl Variance for Binomial
[src]

fn variance(&self) -> f64

Compute the variance.

fn deviation(&self) -> f64

Compute the standard deviation.

fn var(&self) -> f64

Compute the variance. Read more

fn sd(&self) -> f64

Compute the standard deviation. Read more