NAG Library Routine Document
G05YMF
1 Purpose
G05YMF generates a uniformly distributed lowdiscrepancy sequence as proposed by Sobol, Faure or Niederreiter. It must be preceded by a call to one of the initialization routines
G05YLF or
G05YNF.
2 Specification
INTEGER 
N, RCORD, LDQUAS, IREF($\mathit{liref}$), IFAIL 
REAL (KIND=nag_wp) 
QUAS(LDQUAS,$\mathit{tdquas}$) 

3 Description
Low discrepancy (quasirandom) sequences are used in numerical integration, simulation and optimization. Like pseudorandom numbers they are uniformly distributed but they are not statistically independent, rather they are designed to give more even distribution in multidimensional space (uniformity). Therefore they are often more efficient than pseudorandom numbers in multidimensional Monte–Carlo methods.
G05YMF generates a set of points ${x}^{1},{x}^{2},\dots ,{x}^{N}$ with high uniformity in the $S$dimensional unit cube ${I}^{S}={\left[0,1\right]}^{S}$.
Let
$G$ be a subset of
${I}^{S}$ and define the counting function
${S}_{N}\left(G\right)$ as the number of points
${x}^{i}\in G$. For each
$x=\left({x}_{1},{x}_{2},\dots ,{x}_{S}\right)\in {I}^{S}$, let
${G}_{x}$ be the rectangular
$S$dimensional region
with volume
${x}_{1},{x}_{2},\dots ,{x}_{S}$. Then one measure of the uniformity of the points
${x}^{1},{x}^{2},\dots ,{x}^{N}$ is the discrepancy:
which has the form
The principal aim in the construction of lowdiscrepancy sequences is to find sequences of points in ${I}^{S}$ with a bound of this form where the constant ${C}_{S}$ is as small as possible.
The type of lowdiscrepancy sequence generated by G05YMF depends on the initialization routine called and can include those proposed by Sobol, Faure or Niederreiter. If the initialization routine
G05YNF was used then the sequence will be scrambled (see
Section 3 in G05YNF for details).
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
5 Arguments
Note: the following variables are used in the parameter descriptions:

$\mathit{idim}={\mathbf{IDIM}}$, the number of dimensions required, see G05YLF or G05YNF

$\mathit{liref}={\mathbf{LIREF}}$, the length of IREF as supplied to the initialization routine G05YLF or G05YNF

$\mathit{tdquas}={\mathbf{N}}$ if
${\mathbf{RCORD}}=1$; otherwise
$\mathit{tdquas}=\mathit{idim}$
 1: $\mathrm{N}$ – INTEGERInput

On entry: the number of quasirandom numbers required.
Constraint:
${\mathbf{N}}\ge 0$ and ${\mathbf{N}}+\text{previous number of generated values}\le {2}^{31}1$.
 2: $\mathrm{RCORD}$ – INTEGERInput

On entry: the order in which the generated values are returned.
Constraint:
${\mathbf{RCORD}}=1$ or $2$.
 3: $\mathrm{QUAS}\left({\mathbf{LDQUAS}},\mathit{tdquas}\right)$ – REAL (KIND=nag_wp) arrayOutput

On exit: contains the
N quasirandom numbers of dimension
idim.
If ${\mathbf{RCORD}}=1$, ${\mathbf{QUAS}}\left(i,j\right)$ holds the $j$th value for the $i$th dimension.
If ${\mathbf{RCORD}}=2$, ${\mathbf{QUAS}}\left(i,j\right)$ holds the $i$th value for the $j$th dimension.
 4: $\mathrm{LDQUAS}$ – INTEGERInput

On entry: the first dimension of the array
QUAS as declared in the (sub)program from which G05YMF is called.
Constraints:
 if ${\mathbf{RCORD}}=1$, ${\mathbf{LDQUAS}}\ge \mathit{idim}$;
 if ${\mathbf{RCORD}}=2$, ${\mathbf{LDQUAS}}\ge {\mathbf{N}}$.
 5: $\mathrm{IREF}\left(\mathit{liref}\right)$ – INTEGER arrayCommunication Array

On entry: contains information on the current state of the sequence.
On exit: contains updated information on the state of the sequence.
 6: $\mathrm{IFAIL}$ – INTEGERInput/Output

On entry:
IFAIL must be set to
$0$,
$1\text{ or}1$. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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}}=0$ or
$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{N}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{N}}\ge 0$.
On entry, value of
N would result in too many calls to the generator:
${\mathbf{N}}=\u2329\mathit{\text{value}}\u232a$, generator has previously been called
$\u2329\mathit{\text{value}}\u232a$ times.
 ${\mathbf{IFAIL}}=2$

On entry, ${\mathbf{RCORD}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{RCORD}}=1$ or $2$.
 ${\mathbf{IFAIL}}=4$

On entry, ${\mathbf{LDQUAS}}=\u2329\mathit{\text{value}}\u232a$, $\mathit{idim}=\u2329\mathit{\text{value}}\u232a$.
Constraint: if ${\mathbf{RCORD}}=1$, ${\mathbf{LDQUAS}}\ge \mathit{idim}$.
On entry, ${\mathbf{LDQUAS}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{N}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: if ${\mathbf{RCORD}}=2$, ${\mathbf{LDQUAS}}\ge {\mathbf{N}}$.
 ${\mathbf{IFAIL}}=5$

On entry,
IREF has either not been initialized or has been corrupted.
 ${\mathbf{IFAIL}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{IFAIL}}=399$
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{IFAIL}}=999$
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7 Accuracy
Not applicable.
8 Parallelism and Performance
G05YMF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementationspecific information.
The Sobol, Sobol (A659) and Niederreiter quasirandom number generators in G05YMF have been parallelized, but require quite large problem sizes to see any significant performance gain. Parallelism is only enabled when ${\mathbf{RCORD}}=2$. The Faure generator is serial.
None.
10 Example
This example calls
G05YLF and G05YMF to estimate the value of the integral
In this example the number of dimensions $S$ is set to $8$.
10.1 Program Text
Program Text (g05ymfe.f90)
10.2 Program Data
Program Data (g05ymfe.d)
10.3 Program Results
Program Results (g05ymfe.r)