|
NAG[g05nbc] NAG[nag_rngs_sample] - Pseudo-random sample from an integer vector
|
|
Calling Sequence
g05nbc(ipop, isampl, igen, iseed, 'n'=n, 'm'=m, 'fail'=fail)
nag_rngs_sample(. . .)
Parameters
|
ipop - Vector(1..n, datatype=integer[kernelopts('wordsize')/8]);
|
|
|
On entry: the population to be sampled.
|
|
|
isampl - Vector(1..m, datatype=integer[kernelopts('wordsize')/8]);
|
|
|
On exit: the selected sample.
|
|
|
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.
|
|
|
'n'=n - integer; (optional)
|
|
|
On entry: the number of elements in the population vector to be sampled.
|
|
Constraint: . .
|
|
|
'm'=m - integer; (optional)
|
|
|
On entry: the sample size.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_rngs_sample (g05nbc) selects a pseudo-random sample without replacement from an integer vector.
|
|
Error Indicators and Warnings
|
|
"NE_BAD_PARAM"
On entry, argument had an illegal value.
"NE_INT"
On entry, . Constraint: .
"NE_INT_2"
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.
|
|
Further Comments
|
|
The time taken by nag_rngs_sample (g05nbc) is of order .
In order to sample other kinds of vectors, or matrices of higher dimension, the following technique may be used:
|
a. set , for ;
|
|
b. use nag_rngs_sample (g05nbc) to take a sample from ipop and put it into isampl;
|
|
c. use the contents of isampl as a set of indices to access the relevant vector or matrix.
|
In order to divide a population into several groups, g05nac (nag_rngs_permute) is more efficient.
|
|
|
Examples
|
|
>
|
n := 8:
m := 1:
igen := 1:
ipop := Vector([1, 2, 3, 4, 5, 6, 7, 8], datatype=integer[kernelopts('wordsize')/8]):
isampl := Vector(1, datatype=integer[kernelopts('wordsize')/8]):
iseed := Vector([1762543, 9324783, 1542344, 742355], datatype=integer[kernelopts('wordsize')/8]):
NAG:-g05nbc(ipop, isampl, igen, iseed, 'n' = n, 'm' = m):
|
|
|