g05nd selects a pseudorandom sample without replacement from an integer vector.
Public Shared Sub g05nd ( _ ipop As Integer(), _ n As Integer, _ isampl As Integer(), _ m As Integer, _ g05state As G05..::..G05State, _ <OutAttribute> ByRef ifail As Integer _ )
public: static void g05nd( array<int>^ ipop, int n, array<int>^ isampl, int m, G05..::..G05State^ g05state, [OutAttribute] int% ifail )
- Type: array<System..::..Int32>()An array of size [n]On entry: the population to be sampled.
- Type: System..::..Int32On entry: the number of elements in the population vector to be sampled.Constraint: .
- Type: System..::..Int32On entry: the sample size.Constraint: .
g05nd selects elements from a population vector ipop of length and places them in a sample vector isampl. Their order in ipop will be preserved in isampl. Each of the possible combinations of elements of isampl may be regarded as being equally probable.
For moderate or large values of it is theoretically impossible that all combinations of size may occur, unless is near 1 or near . This is because exceeds the cycle length of any of the base generators. For practical purposes this is irrelevant, as the time taken to generate all possible combinations is many millenia.
One of the initialization methods (G05KFF not in this release) (for a repeatable sequence if computed sequentially) or (G05KGF not in this release) (for a non-repeatable sequence) must be called prior to the first call to g05nd.
Kendall M G and Stuart A (1969) The Advanced Theory of Statistics (Volume 1) (3rd Edition) Griffin
Knuth D E (1981) The Art of Computer Programming (Volume 2) (2nd Edition) Addison–Wesley
Errors or warnings detected by the method:
- On entry, .
On entry, , or . On entry, state vector was not initialized or has been corrupted.
The time taken by g05nd 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 g05nd 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, g05nc is more efficient.