nag_return_discrete (g05eyc) returns a pseudorandom integer taken from a discrete distribution defined by a reference vector
r.
nag_return_discrete (g05eyc) is designed for use in conjunction with other functions in this chapter, which set up the reference vector
r for specific distributions or according to a distribution specified in terms of the PDF (probability density function) or CDF (cumulative distribution function). See the
g05 Chapter Introduction.
The function generates a random number
from
nag_random_continuous_uniform (g05cac) and searches the CDF in
r for the smallest value
such that CDF
and CDF
.
None.
Not applicable.
None.
The example program calls
nag_ref_vec_poisson (g05ecc) to set up a reference vector for a Poisson distribution with mean 2.7; it then prints the first five pseudorandom numbers generated by nag_return_discrete (g05eyc) after initialization by
nag_random_init_repeatable (g05cbc).
None.