g05nd Method
関数リスト一覧   NagLibrary Namespaceへ  ライブラリイントロダクション  本ヘルプドキュメントのchm形式版

g05nd selects a pseudorandom sample without replacement from an integer vector.

Syntax

C#
public static void g05nd(
	int[] ipop,
	int n,
	int[] isampl,
	int m,
	G05..::.G05State g05state,
	out int ifail
)
Visual Basic (Declaration)
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 _
)
Visual C++
public:
static void g05nd(
	array<int>^ ipop, 
	int n, 
	array<int>^ isampl, 
	int m, 
	G05..::.G05State^ g05state, 
	[OutAttribute] int% ifail
)
F#
static member g05nd : 
        ipop:int[] * 
        n:int * 
        isampl:int[] * 
        m:int * 
        g05state:G05..::.G05State * 
        ifail:int byref -> unit 

Parameters

ipop
Type: array< System..::.Int32 >[]()[]
An array of size [n]
On entry: the population to be sampled.
n
Type: System..::.Int32
On entry: the number of elements in the population vector to be sampled.
Constraint: n1.
isampl
Type: array< System..::.Int32 >[]()[]
An array of size [m]
On exit: the selected sample.
m
Type: System..::.Int32
On entry: the sample size.
Constraint: 1mn.
g05state
Type: NagLibrary..::.G05..::.G05State
An object of type G05.G05State.
ifail
Type: System..::.Int32 %
On exit: ifail=0 unless the method detects an error (see [Error Indicators and Warnings]).

Description

g05nd selects m elements from a population vector ipop of length n and places them in a sample vector isampl. Their order in ipop will be preserved in isampl. Each of the n m  possible combinations of elements of isampl may be regarded as being equally probable.
For moderate or large values of n it is theoretically impossible that all combinations of size m may occur, unless m is near 1 or near n. This is because n m  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.

References

Error Indicators and Warnings

Accuracy

Further Comments

In order to sample other kinds of vectors, or matrices of higher dimension, the following technique may be used:
(a) set ipop[i-1]=i, for i=1,2,,n;
(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.

Example

See Also