nag_rand_geom (g05tcc) generates a vector of pseudorandom integers from the discrete geometric distribution with probability of success at a trial.
nag_rand_geom (g05tcc) 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 nag_rand_geom (g05tcc) 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 functions
nag_rand_init_repeatable (g05kfc) (for a repeatable sequence if computed sequentially) or
nag_rand_init_nonrepeatable (g05kgc) (for a non-repeatable sequence) must be called prior to the first call to nag_rand_geom (g05tcc).
Not applicable.
nag_rand_geom (g05tcc) 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 function. 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
.
This example prints
pseudorandom integers from a geometric distribution with parameter
, generated by a single call to nag_rand_geom (g05tcc), after initialization by
nag_rand_init_repeatable (g05kfc).
None.