g05pz generates a random two-way table.
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 _ )
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 )
- Type: System..::..Int32On entry: a code for selecting the operation to be performed by the method.
Constraint: , or .
- 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.
- Type: System..::..Int32On entry: , the number of rows in the table.Constraint: .
- Type: System..::..Int32On entry: , the number of columns in the table.Constraint: .
- Type: array<System..::..Int32>()An array of size [nrow]On entry: the row totals, , for .Constraints:
- , for ;
- , for .
- Type: array<System..::..Int32>()An array of size [ncol]On entry: the column totals, , for .Constraints:
- , for ;
- 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.
- 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
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.
Patefield W M (1981) An efficient method of generating tables with given row and column totals Appl. Stats. 30 91–97
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, state vector was not initialized or has been corrupted.