G05 Chapter Contents
G05 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG05YLF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G05YLF initializes a quasi-random generator prior to calling G05YJF, G05YKF or G05YMF.

## 2  Specification

 SUBROUTINE G05YLF ( GENID, IDIM, IREF, LIREF, ISKIP, IFAIL)
 INTEGER GENID, IDIM, IREF(LIREF), LIREF, ISKIP, IFAIL

## 3  Description

G05YLF selects a quasi-random number generator through the input value of GENID and initializes the IREF communication array for use by the routines G05YJF, G05YKF or G05YMF.
One of three types of quasi-random generator may be chosen, allowing the low-discrepancy sequences proposed by Sobol, Faure or Niederreiter to be generated.
Two sets of Sobol sequences are supplied, the first, is based on the work of Joe and Kuo (2008). The second, referred to in the documentation as "Sobol (A659)", is based on Algorithm 659 of Bratley and Fox (1988) with the extension to 1111 dimensions proposed by Joe and Kuo (2003). Both sets of Sobol sequences should satisfy the so-called Property A, up to $1111$ dimensions, but the first set should have better two-dimensional projections than those produced using Algorithm 659.

## 4  References

Bratley P and Fox B L (1988) Algorithm 659: implementing Sobol's quasirandom sequence generator ACM Trans. Math. Software 14(1) 88–100
Fox B L (1986) Algorithm 647: implementation and relative efficiency of quasirandom sequence generators ACM Trans. Math. Software 12(4) 362–376
Joe S and Kuo F Y (2003) Remark on Algorithm 659: implementing Sobol's quasirandom sequence generator ACM Trans. Math. Software (TOMS) 29 49–57
Joe S and Kuo F Y (2008) Constructing Sobol sequences with better two-dimensional projections SIAM J. Sci. Comput. 30 2635–2654

## 5  Parameters

1:     GENID – INTEGERInput
On entry: must identify the quasi-random generator to use.
${\mathbf{GENID}}=1$
Sobol generator.
${\mathbf{GENID}}=2$
Sobol (A659) generator.
${\mathbf{GENID}}=3$
Niederreiter generator.
${\mathbf{GENID}}=4$
Faure generator.
Constraint: ${\mathbf{GENID}}=1$, $2$, $3$ or $4$.
2:     IDIM – INTEGERInput
On entry: the number of dimensions required.
Constraints:
• if ${\mathbf{GENID}}=1$, $1\le {\mathbf{IDIM}}\le 10000$;
• if ${\mathbf{GENID}}=2$, $1\le {\mathbf{IDIM}}\le 1111$;
• if ${\mathbf{GENID}}=3$, $1\le {\mathbf{IDIM}}\le 318$;
• if ${\mathbf{GENID}}=4$, $1\le {\mathbf{IDIM}}\le 40$.
3:     IREF(LIREF) – INTEGER arrayCommunication Array
On exit: contains initialization information for use by the generator routines G05YJF, G05YKF and G05YMF. IREF must not be altered in any way between initialization and calls of the generator routines.
4:     LIREF – INTEGERInput
On entry: the dimension of the array IREF as declared in the (sub)program from which G05YLF is called.
Constraints:
• if ${\mathbf{GENID}}=1$, $2$ or $3$, ${\mathbf{LIREF}}\ge 32×{\mathbf{IDIM}}+7$;
• if ${\mathbf{GENID}}=4$, ${\mathbf{LIREF}}\ge 407$.
5:     ISKIP – INTEGERInput
On entry: the number of terms of the sequence to skip on initialization for the Sobol and Niederreiter generators. If ${\mathbf{GENID}}=4$, ISKIP is ignored.
Constraint: if ${\mathbf{GENID}}=1$, $2$ or $3$, $0\le {\mathbf{ISKIP}}\le {2}^{30}$.
6:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{GENID}}<1$, or ${\mathbf{GENID}}>4$.
${\mathbf{IFAIL}}=2$
 On entry, ${\mathbf{IDIM}}<1$, or IDIM is too large.
${\mathbf{IFAIL}}=4$
On entry, LIREF is too small.
${\mathbf{IFAIL}}=5$
The value of ${\mathbf{ISKIP}}<0$ or ISKIP is too large.

## 7  Accuracy

Not applicable.

The primitive polynomials and direction numbers used for the Sobol generator (${\mathbf{GENID}}=1$) were calculated by Joe and Kuo (2008) using the search critera ${D}^{\left(6\right)}$.