RandomNextBinomial Method |
Generate a pseudorandom number from a Binomial distribution.
Namespace: Imsl.StatAssembly: ImslCS (in ImslCS.dll) Version: 6.5.2.0
Syntax public virtual int NextBinomial(
int n,
double p
)
Public Overridable Function NextBinomial (
n As Integer,
p As Double
) As Integer
public:
virtual int NextBinomial(
int n,
double p
)
abstract NextBinomial :
n : int *
p : float -> int
override NextBinomial :
n : int *
p : float -> int
Parameters
- n
- Type: SystemInt32
A int which specifies the number of Bernoulli trials.
- p
- Type: SystemDouble
A double which specifies the probability of success on each
trial, .
Return Value
Type:
Int32
A
int which specifies the pseudorandom number from a Binomial
distribution.
Remarks NextBinomial generates pseudorandom numbers from a Binomial
distribution with parameters n and p. n and
p must be positive, and p must be less than 1. The
probability function (with n = n and p = p) is
for .
The algorithm used depends on the values of n and p. If
or if p is less than a machine
epsilon, the inverse CDF technique is used; otherwise, the BTPE
algorithm of Kachitvichyanukul and Schmeiser (see Kachitvichyanukul
1982) is used. This is an acceptance/rejection method using a
composition of four regions. (TPE equals Triangle, Parallelogram,
Exponential, left and right.)
See Also