|
NAG[g05mlc] NAG[nag_rngs_hypergeometric] - Generates a vector of random integers from a hypergeometric distribution, seeds and generator number passed explicitly
|
|
Calling Sequence
g05mlc(mode, ns, np, m, x, igen, iseed, r, 'n'=n, 'fail'=fail)
nag_rngs_hypergeometric(. . .)
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_hypergeometric (g05mlc).
|
|
Set up reference vector and generate variates.
|
|
Generate variates without using the reference vector.
|
|
Constraint: . .
|
|
|
ns - integer;
|
|
|
On entry: , the sample size of the hypergeometric distribution.
|
|
Constraint: . .
|
|
|
np - integer;
|
|
|
On entry: , the population size of the hypergeometric distribution.
|
|
Constraint: . .
|
|
|
m - integer;
|
|
|
On entry: , the number of specified items of the hypergeometric distribution.
|
|
Constraint: . .
|
|
|
x - Vector(1..n, datatype=integer[kernelopts('wordsize')/8]);
|
|
|
On exit: the pseudo-random numbers from the specified hypergeometric 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]);
|
|
|
Note: the dimension, dim, of the array r must be at least .
|
|
On entry: if mode is set to , the reference vector from the previous call to nag_rngs_hypergeometric (g05mlc).
|
|
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_hypergeometric (g05mlc) generates a vector of pseudo-random integers from the discrete hypergeometric distribution of the number of specified items in a sample of size , taken from a population of size with specified items in it.
|
|
Description
|
|
nag_rngs_hypergeometric (g05mlc) generates integers from a discrete hypergeometric distribution, where the probability of 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_hypergeometric (g05mlc) with the same argument values can then use this reference vector to generate further variates. The reference array is generated by a recurrence relation if , otherwise Stirling's approximation 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_hypergeometric (g05mlc).
|
|
Error Indicators and Warnings
|
|
"NE_BAD_PARAM"
On entry, argument had an illegal value.
"NE_INT"
On entry, . Constraint: .
On entry, . Constraint: .
On entry, . Constraint: .
"NE_INT_2"
On entry, or : , .
On entry, or : , .
"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"
ns or np or m is not the same as when r was set up in a previous call or the data in r has been corrupted.
|
|
|
Examples
|
|
>
|
mode := 2:
ns := 500:
np := 1000:
m := 900:
n := 20:
igen := 1:
x := Vector(20, datatype=integer[kernelopts('wordsize')/8]):
iseed := Vector([1762543, 9324783, 42344, 742355], datatype=integer[kernelopts('wordsize')/8]):
r := Vector(2519, datatype=float[8]):
# Initialise seeds
NAG:-g05kbc(igen, iseed):
NAG:-g05mlc(mode, ns, np, m, x, igen, iseed, r, 'n' = n):
|
|
|