Namespace:
Imsl.Stat
Assembly:
ImslCS (in ImslCS.dll) Version: 6.5.0.0
Syntax
C# |
---|
public virtual int NextNegativeBinomial( double rk, double p ) |
Visual Basic (Declaration) |
---|
Public Overridable Function NextNegativeBinomial ( _ rk As Double, _ p As Double _ ) As Integer |
Visual C++ |
---|
public: virtual int NextNegativeBinomial( double rk, double p ) |
Parameters
- rk
- Type: System..::.Double
A double which specifies the negative binomial parameter,.
- p
- Type: System..::.Double
A double which specifies the probability of success on each trial. It must be greater than machine precision and less than one.
Return Value
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
and
.
and
must be
positive and p must be less than 1. The probability function
with (
and
) is

for .
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, 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
.
If rp/(1 - p) is less than 100 and
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.