Negative Binomial Distribution Function
JavaScript
If independent trials with probability p of success at each trial
are performed until the rth failure occurs, then the distribution
of the observed number of successes follows the negative binomial
distribution, NB(r,p), with probability mass function,
f(x | r,p) = Cr+x-1,x, (1-p)r px for x =
0,1,2,...
where Cr+x-1,x, is the number of combinations of r+x-1 things
taken x at a time. The important special case, r=1, is the
geometric distribution, NB(1,p). For example, F(0 | 1,.5)=.5