G05TCF generates a vector of pseudorandom integers from the discrete geometric distribution with probability $p$ of success at a trial.
G05TCF generates
$n$ integers
${x}_{i}$ from a discrete geometric distribution, where the probability of
${x}_{i}=I$ (a first success after
$I+1$ 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 $p$) 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
${\mathbf{IFAIL}}={\mathbf{0}}$ or
${-{\mathbf{1}}}$, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Not applicable.
G05TCF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
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
${\mathbf{MODE}}=3$.
This example prints
$10$ pseudorandom integers from a geometric distribution with parameter
$p=0.001$, generated by a single call to G05TCF, after initialization by
G05KFF.