g05pz generates a random two-way table.
Syntax
C# |
---|
public static void g05pz( int mode, int nrow, int ncol, int[] totr, int[] totc, double[] r, G05..::..G05State g05state, int[,] x, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g05pz ( _ mode As Integer, _ nrow As Integer, _ ncol As Integer, _ totr As Integer(), _ totc As Integer(), _ r As Double(), _ g05state As G05..::..G05State, _ x As Integer(,), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void g05pz( int mode, int nrow, int ncol, array<int>^ totr, array<int>^ totc, array<double>^ r, G05..::..G05State^ g05state, array<int,2>^ x, [OutAttribute] int% ifail ) |
F# |
---|
static member g05pz : mode : int * nrow : int * ncol : int * totr : int[] * totc : int[] * r : float[] * g05state : G05..::..G05State * x : int[,] * ifail : int byref -> unit |
Parameters
- mode
- Type: System..::..Int32On entry: a code for selecting the operation to be performed by the method.
- Set up reference vector only.
- Generate two-way table using reference vector set up in a prior call to g05pz.
- Set up reference vector and generate two-way table.
Constraint: , or .
- nrow
- Type: System..::..Int32On entry: , the number of rows in the table.Constraint: .
- ncol
- Type: System..::..Int32On entry: , the number of columns in the table.Constraint: .
- totr
- Type: array<System..::..Int32>[]()[][]An array of size [nrow]On entry: the row totals, , for .Constraints:
- , for ;
- ;
- , for .
- totc
- Type: array<System..::..Int32>[]()[][]An array of size [ncol]On entry: the column totals, , for .Constraints:
- , for ;
- .
- r
- Type: array<System..::..Double>[]()[][]An array of size [lr]On entry: if , the reference vector from the previous call to g05pz.On exit: the reference vector.
- g05state
- Type: NagLibrary..::..G05..::..G05StateAn Object of type G05.G05State.
- x
- Type: array<System..::..Int32,2>[,](,)[,][,]An array of size [dim1, ncol]Note: dim1 must satisfy the constraint:On exit: if or , a pseudorandom two-way by table, , with element containing the th entry in the table such that and
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
Given row totals and column totals (with , say),
g05pz will generate a pseudorandom two-way table of integers such that the row and column totals are satisfied.
The method used is based on that described by
Patefield (1981) which is most efficient when is large relative to the number of table entries (i.e.,
). Entries are generated one row at a time and one entry at a time within a row. Each entry is generated using the conditional probability distribution for that entry given the entries in the previous rows and the previous entries in the same row.
A reference vector is used to store computed values that can be reused in the generation of new tables with the same row and column totals. g05pz can be called to simply set up the reference vector, or to generate a two-way table using a reference vector set up in a previous call, or it can combine both functions in a single call.
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 g05pz.
References
Patefield W M (1981) An efficient method of generating tables with given row and column totals Appl. Stats. 30 91–97
Error Indicators and Warnings
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface
(LDX) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.
- On entry, , or .
On entry, .
On entry, .
- At least one element of totr is negative.
- At least one element of totc is negative.
On entry, lr is too small when or (see [Parameters]).
On entry, state vector was not initialized or has been corrupted.
Accuracy
None.
Parallelism and Performance
None.
Further Comments
None.