Generate a pseudorandom number from a geometric distribution.
double
which specifies the probability of success on each trial, . A int
which specifies a pseudorandom number from a geometric distribution.
NextGeometric
generates pseudorandom numbers from a geometric distribution with parameter p, where P =p is the probability of getting a success on any trial. A geometric deviate can be interpreted as the number of trials until the first success (including the trial in which the first success is obtained). The probability function is
for and
.The geometric distribution as defined above has mean 1/P.
The i-th geometric deviate is generated as the smallest integer not less than , where the are independent uniform (0, 1) random numbers (see Knuth, 1981).
The geometric distribution is often defined on 0, 1, 2, ..., with mean (1 - P)/P. Such deviates can be obtained by subtracting 1 from each element returned value.
Random Class | Imsl.Stat Namespace | Example