random variable X
can be represented as the sum of n
independent Bernoulli random variables for which probability of assuming a 1
and the probability of assuming a 0
is 1 - p
then takes on the values 0,...,n
with the point probability distribution
|f(i) = |
|Cni p i (1 - p) n-i|| for i = 0,...,n|
is the combination of n
things taken i
at a time.
- int Binomial_Random_Variate( int n, double p )
This function returns X where X is the Binomial(n,p) random variate described above.
source code is available for this routine: