Statistics.Distributions.Binomial (statistics v0.6.3)
Binomial distribution.
This models the expected outcome of a number of binary trials, each with known probability, (often called a Bernoulli trial)
Summary
Functions
The cumulative density function
The probability mass function.
The percentile-point function
Draw a random number from a binomial distribution
Functions
Link to this function
cdf(n, p)
@spec cdf(non_neg_integer(), number()) :: (... -> any())
The cumulative density function
Examples
iex> Statistics.Distributions.Binomial.cdf(4, 0.5).(2)
0.6875
Link to this function
pmf(n, p)
@spec pmf(non_neg_integer(), number()) :: (... -> any())
The probability mass function.
Note that calling the mass function with a Float
will return nil
because
this is a discrete probability distribution which only includes integer values.
Examples
iex> Statistics.Distributions.Binomial.pmf(4, 0.5).(2)
0.375
iex> Statistics.Distributions.Binomial.pmf(4, 0.5).(0.2)
nil
Link to this function
ppf(n, p)
@spec ppf(non_neg_integer(), number()) :: (... -> any())
The percentile-point function
Examples
iex> Statistics.Distributions.Binomial.ppf(10, 0.5).(0.5)
5
Link to this function
rand(n, p)
@spec rand(non_neg_integer(), number()) :: non_neg_integer()
Draw a random number from a binomial distribution
Uses the rejection sampling method
and returns a rounded Float
.
Examples
iex> Statistics.Distributions.Binomial.rand(10, 0.5)
5.0