NAG Library Routine Document
g05yjf
(quasi_normal)
1
Purpose
g05yjf generates a quasirandom sequence from a Normal (Gaussian) distribution. It must be preceded by a call to one of the initialization routines
g05ylf or
g05ynf.
2
Specification
Fortran Interface
Integer, Intent (In)  :: 
n  Integer, Intent (Inout)  :: 
iref($\mathit{liref}$),
ifail  Real (Kind=nag_wp), Intent (In)  :: 
xmean($\mathit{idim}$),
std($\mathit{idim}$)  Real (Kind=nag_wp), Intent (Inout)  :: 
quas(n,$\mathit{idim}$) 

C Header Interface
#include nagmk26.h
void 
g05yjf_ (
const double xmean[],
const double std[],
const Integer *n,
double quas[],
Integer iref[],
Integer *ifail) 

3
Description
g05yjf generates a quasirandom sequence from a Normal distribution by first generating a uniform quasirandom sequence which is then transformed into a Normal sequence using the inverse of the Normal CDF. The type of uniform sequence used depends on the initialization routine called and can include the lowdiscrepancy sequences proposed by Sobol, Faure or Niederreiter. If the initialization routine
g05ynf was used then the underlying uniform sequence is first scrambled prior to being transformed (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
Wichura (1988) Algorithm AS 241: the percentage points of the Normal distribution Appl. Statist. 37 477–484
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 routines g05ylf or g05ynf.
 1: $\mathbf{xmean}\left(\mathit{idim}\right)$ – Real (Kind=nag_wp) arrayInput

On entry: specifies, for each dimension, the mean of the Normal distribution.
 2: $\mathbf{std}\left(\mathit{idim}\right)$ – Real (Kind=nag_wp) arrayInput

On entry: specifies, for each dimension, the standard deviation of the Normal distribution.
Constraint:
${\mathbf{std}}\left(\mathit{i}\right)\ge 0.0$, for $\mathit{i}=1,2,\dots ,\mathit{idim}$.
 3: $\mathbf{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$.
 4: $\mathbf{quas}\left({\mathbf{n}},\mathit{idim}\right)$ – Real (Kind=nag_wp) arrayOutput

On exit: contains the
n quasirandom numbers of dimension
idim
 5: $\mathbf{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: $\mathbf{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, incorrect initialization has been detected.
 ${\mathbf{ifail}}=2$

On entry,  ${\mathbf{n}}<1$. 
 ${\mathbf{ifail}}=3$

A standard deviation is negative.
 ${\mathbf{ifail}}=4$

There have been too many calls to the generator.
 ${\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
g05yjf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g05yjf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
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 g05yjf have been parallelized, but require quite large problem sizes to see any significant performance gain. The Faure generator is serial.
None.
10
Example
This example calls
g05ylf to initialize the generator and then
g05yjf to generate a sequence of five fourdimensional variates.
10.1
Program Text
Program Text (g05yjfe.f90)
10.2
Program Data
Program Data (g05yjfe.d)
10.3
Program Results
Program Results (g05yjfe.r)