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. g05pzc 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 functions
g05kfc (for a repeatable sequence if computed sequentially) or
g05kgc (for a non-repeatable sequence) must be called prior to the first call to
g05pzc.
-
1:
– Nag_ModeRNG
Input
-
On entry: a code for selecting the operation to be performed by the function.
- Set up reference vector only.
- Generate two-way table using reference vector set up in a prior call to g05pzc.
- Set up reference vector and generate two-way table.
Constraint:
, or .
-
2:
– Integer
Input
-
On entry: , the number of rows in the table.
Constraint:
.
-
3:
– Integer
Input
-
On entry: , the number of columns in the table.
Constraint:
.
-
4:
– const Integer
Input
-
On entry: the row totals,
, for .
Constraints:
- , for ;
- ;
- , for .
-
5:
– const Integer
Input
-
On entry: the column totals,
, for .
Constraints:
- , for ;
- .
-
6:
– double
Communication Array
-
On entry: if , the reference vector from the previous call to g05pzc.
On exit: the reference vector.
-
7:
– Integer
Input
-
On entry: the dimension of the array
r.
Constraint:
.
-
8:
– Integer
Communication Array
Note: the dimension,
, of this array is dictated by the requirements of associated functions that must have been previously called. This array MUST be the same array passed as argument
state in the previous call to
nag_rand_init_repeatable (g05kfc) or
nag_rand_init_nonrepeatable (g05kgc).
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
-
9:
– Integer
Output
-
On exit: if or , a pseudorandom two-way table, , with element containing the th entry in the table such that and
-
10:
– Integer
Input
-
On entry: the stride separating matrix column elements in the array
x.
Constraint:
.
-
11:
– NagError *
Input/Output
-
The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
Not applicable.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
None.
Following initialization of the pseudorandom number generator by a call to
g05kfc, this example generates and prints a
two-way table, with row totals of
,
,
and
respectively, and column totals of
,
and
respectively.
None.