G05TCF generates a vector of pseudorandom integers from the discrete geometric distribution with probability of success at a trial.
G05TCF generates
integers
from a discrete geometric distribution, where the probability of
(a first success after
trials) is
The variates can be generated with or without using a search table and index. If a search table is used then it is stored with the index in a reference vector and subsequent calls to G05TCF with the same parameter value can then use this reference vector to generate further variates. If the search table is not used (as recommended for small values of ) then a direct transformation of uniform variates is used.
One of the initialization routines
G05KFF (for a repeatable sequence if computed sequentially) or
G05KGF (for a non-repeatable sequence) must be called prior to the first call to G05TCF.
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Not applicable.
The time taken to set up the reference vector, if used, increases with the length of array
R. However, if the reference vector is used, the time taken to generate numbers decreases as the space allotted to the index part of
R increases. Nevertheless, there is a point, depending on the distribution, where this improvement becomes very small and the suggested value for the length of array
R is designed to approximate this point.
If
P is very small then the storage requirements for the reference vector and the time taken to set up the reference vector becomes prohibitive. In this case it is recommended that the reference vector is not used. This is achieved by selecting
.
This example prints
pseudorandom integers from a geometric distribution with parameter
, generated by a single call to G05TCF, after initialization by
G05KFF.