A Negative Binomial(n,p)
random variable X
can be represented the number of 0
's which occur before n 1's
occur when sampling independent Bernoulli random variables for which probability of assuming a 1
and the probability of assuming a 0
then takes on the values k = 0, 1, ...
with the point probability distribution
|Pr[ X = k ] = f(k) = Cn + k - 1k pn ( 1 - p )k|| for k = 0,... .|
- int Negative_Binomial_Random_Variate( int n, double p )
This function returns X where X is the Negative Binomial(n,p) random variate described above.
source code is available for this routine: