|
NAG[g05mbc] NAG[nag_rngs_geom] - Generates a vector of random integers from a geometric distribution, seeds and generator number passed explicitly
|
|
Calling Sequence
g05mbc(mode, p, x, igen, iseed, r, 'n'=n, 'fail'=fail)
nag_rngs_geom(. . .)
Parameters
|
mode - integer;
|
|
|
On entry: a code for selecting the operation to be performed by the function:
|
|
Set up reference vector only.
|
|
Generate variates using reference vector set up in a prior call to nag_rngs_geom (g05mbc).
|
|
Set up reference vector and generate variates.
|
|
Generate variates without using the reference vector.
|
|
Constraint: . .
|
|
|
p - float;
|
|
|
On entry: the argument of the geometric distribution representing the probability of success at a single trial.
|
|
Constraint: . .
|
|
|
x - Vector(1..n, datatype=integer[kernelopts('wordsize')/8]);
|
|
|
On exit: the pseudo-random numbers from the specified geometric distribution.
|
|
|
iseed - Vector(1.. , datatype=integer[kernelopts('wordsize')/8]);
|
|
|
On entry: contains values which define the current state of the selected generator.
|
|
On exit: contains updated values defining the new state of the selected generator.
|
|
|
r - Vector(1.. , datatype=float[8]);
|
|
|
On entry: if mode is set to , the reference vector from the previous call to nag_rngs_geom (g05mbc).
|
|
On exit: the reference vector.
|
|
|
'n'=n - integer; (optional)
|
|
|
On entry: , the number of pseudo-random numbers to be generated.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_rngs_geom (g05mbc) generates a vector of pseudo-random integers from the discrete geometric distribution with probability of success at a trial.
|
|
Description
|
|
nag_rngs_geom (g05mbc) 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_rngs_geom (g05mbc) with the same argument 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 g05kbc (nag_rngs_init_repeatable) (for a repeatable sequence if computed sequentially) or g05kcc (nag_rngs_init_nonrepeatable) (for a non-repeatable sequence) must be called prior to the first call to nag_rngs_geom (g05mbc).
|
|
Error Indicators and Warnings
|
|
"NE_BAD_PARAM"
On entry, argument had an illegal value.
"NE_DIM_INFEASIBLE"
p is so small that the reference vector length would exceed integer range We recommend setting . .
"NE_INT"
On entry, . Constraint: .
On entry, . Constraint: .
"NE_INTERNAL_ERROR"
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please consult NAG for assistance.
"NE_PREV_CALL"
p is not the same as when r was set up in a previous call. Previous value , .
"NE_REAL"
On entry, or : .
|
|
Further Comments
|
|
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. There is a point, depending on the distribution, where this improvement becomes very small and the recommended values for the length of array r in other functions are 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 .
|
|
|
Examples
|
|
>
|
mode := 3:
p := 0.001:
n := 10:
igen := 1:
x := Vector(10, datatype=integer[kernelopts('wordsize')/8]):
iseed := Vector([1762543, 9324783, 423441, 742355], datatype=integer[kernelopts('wordsize')/8]):
r := Vector(1, datatype=float[8]):
NAG:-g05mbc(mode, p, x, igen, iseed, r, 'n' = n):
|
|
|