Click or drag to resize
RandomNextNegativeBinomial Method
Generate a pseudorandom number from a negative Binomial distribution.

Namespace: Imsl.Stat
Assembly: ImslCS (in ImslCS.dll) Version: 6.5.2.0
Syntax
public virtual int NextNegativeBinomial(
	double rk,
	double p
)

Parameters

rk
Type: SystemDouble
A double which specifies the negative binomial parameter, rk \gt 0.
p
Type: SystemDouble
A double which specifies the probability of success on each trial. It must be greater than machine precision and less than one.

Return Value

Type: Int32
A int which specifies the pseudorandom number from a negative binomial distribution. If rk is an integer, the deviate can be thought of as the number of failures in a sequence of Bernoulli trials before rk successes occur.
Remarks

Method NextNegativeBinomial generates pseudorandom numbers from a negative Binomial distribution with parameters \rm rk and \rm p. \rm rk and \rm p must be positive and p must be less than 1. The probability function with (r = \rm rk and p = \rm p) is

f\left( x \right) = \left( 
            \begin{array}{c} r + x - 1 \\  x \\  \end{array} \right)\left( {1 - 
            p} \right)^r p^x

for x = 0, 1, 2, \ldots.

If r is an integer, the distribution is often called the Pascal distribution and can be thought of as modeling the length of a sequence of Bernoulli trials until r successes are obtained, where p is the probability of getting a success on any trial. In this form, the random variable takes values r, r + 1, r + 2, \ldots and can be obtained from the negative binomial random variable defined above by adding r to the negative binomial variable. This latter form is also equivalent to the sum of r geometric random variables defined as taking values 1, 2, 3, \ldots.

If rp/(1 - p) is less than 100 and (1 - p)^r is greater than the machine epsilon, NextNegativeBinomial uses the inverse CDF technique; otherwise, for each negative binomial deviate, NextNegativeBinomial generates a gamma (r, p/(1 - p)) deviate y and then generates a Poisson deviate with parameter y.

See Also