# NAG FL Interfaceg05yqf (quasi_​normal_​bydim)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

g05yqf generates a quasi-random sequence from a Normal (Gaussian) distribution. Values are generated for a subset of dimensions. It must be preceded by a call to one of the initialization routines g05ylf or g05ynf.

## 2Specification

Fortran Interface
 Subroutine g05yqf ( n, std, fdim, ldim, quas, iref,
 Integer, Intent (In) :: sorder, n, fdim, ldim, ldquas Integer, Intent (Inout) :: iref(*), ifail Real (Kind=nag_wp), Intent (In) :: xmean(*), std(*) Real (Kind=nag_wp), Intent (Inout) :: quas(ldquas,*)
#include <nag.h>
 void g05yqf_ (const Integer *sorder, const Integer *n, const double xmean[], const double std[], const Integer *fdim, const Integer *ldim, double quas[], const Integer *ldquas, Integer iref[], Integer *ifail)
The routine may be called by the names g05yqf or nagf_rand_quasi_normal_bydim.

## 3Description

g05yqf generates a quasi-random sequence, for a specified subset of dimensions, from a Normal distribution by first generating a uniform quasi-random sequence, for the specified subset of dimensions, 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 low-discrepancy 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).

## 4References

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

## 5Arguments

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
1: $\mathbf{sorder}$Integer Input
On entry: the order in which the generated values are returned.
Constraint: ${\mathbf{sorder}}=1$ or $2$.
2: $\mathbf{n}$Integer Input
On entry: the number of quasi-random numbers required.
Constraint: ${\mathbf{n}}\ge 0$ and ${\mathbf{n}}+\text{previous number of generated values}\le {2}^{31}-1$.
3: $\mathbf{xmean}\left(*\right)$Real (Kind=nag_wp) array Input
Note: the dimension of the array xmean must be at least $\mathit{idim}$.
On entry: specifies, for each dimension, the mean of the Normal distribution.
4: $\mathbf{std}\left(*\right)$Real (Kind=nag_wp) array Input
Note: the dimension of the array std must be at least $\mathit{idim}$.
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}$.
5: $\mathbf{fdim}$Integer Input
On entry: the first dimension to return.
Constraint: $1\le {\mathbf{fdim}}\le {\mathbf{ldim}}$.
6: $\mathbf{ldim}$Integer Input
On entry: the last dimension to return.
Constraint: ${\mathbf{ldim}}\le \mathit{idim}$.
7: $\mathbf{quas}\left({\mathbf{ldquas}},*\right)$Real (Kind=nag_wp) array Output
Note: the second dimension of the array quas must be at least ${\mathbf{ldim}}-{\mathbf{fdim}}+1$ if ${\mathbf{sorder}}=1$ and at least ${\mathbf{n}}$ if ${\mathbf{sorder}}=2$.
On exit: contains the n quasi-random numbers for the required dimensions of a sequence with idim dimensions.
For $i=1,2,\dots ,{\mathbf{n}}$, $j={\mathbf{fdim}},{\mathbf{fdim}}+1,\dots ,{\mathbf{ldim}}$ and $k=\mathit{j}-{\mathbf{fdim}}+1$, the $\mathit{i}$th value for the $\mathit{j}$th dimension is held in
• ${\mathbf{quas}}\left(\mathit{i},k\right)$, if ${\mathbf{sorder}}=1$,
• ${\mathbf{quas}}\left(k,\mathit{i}\right)$, if ${\mathbf{sorder}}=2$.
8: $\mathbf{ldquas}$Integer Input
On entry: the first dimension of the array quas as declared in the (sub)program from which g05yqf is called.
Constraints:
• if ${\mathbf{sorder}}=1$, ${\mathbf{ldquas}}\ge {\mathbf{n}}$;
• if ${\mathbf{sorder}}=2$, ${\mathbf{ldquas}}\ge {\mathbf{ldim}}-{\mathbf{fdim}}+1$.
9: $\mathbf{iref}\left(*\right)$Integer array Communication Array
Note: the dimension of the array iref must be at least $\mathit{liref}$.
On entry: contains information on the current state of the sequence.
On exit: contains updated information on the state of the sequence.
10: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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).

## 6Error 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}}=11$
On entry, ${\mathbf{sorder}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{sorder}}=1$ or $2$.
${\mathbf{ifail}}=21$
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
${\mathbf{ifail}}=22$
On entry, value of n would result in too many calls to the generator: ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$, generator has previously been called $⟨\mathit{\text{value}}⟩$ times.
${\mathbf{ifail}}=41$
On entry, $i=⟨\mathit{\text{value}}⟩$ and ${\mathbf{std}}\left(i\right)=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{std}}\left(i\right)\ge 0.0$.
${\mathbf{ifail}}=61$
On entry, ${\mathbf{fdim}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ldim}}=⟨\mathit{\text{value}}⟩$.
Constraint: $1\le {\mathbf{fdim}}\le {\mathbf{ldim}}$
${\mathbf{ifail}}=71$
On entry, ${\mathbf{ldim}}=⟨\mathit{\text{value}}⟩$ and $\mathit{idim}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldim}}\le \mathit{idim}$
${\mathbf{ifail}}=91$
On entry, ${\mathbf{ldquas}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldquas}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=92$
On entry, ${\mathbf{ldquas}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ldim}}-{\mathbf{fdim}}+1=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldquas}}\ge {\mathbf{ldim}}-{\mathbf{fdim}}+1$.
${\mathbf{ifail}}=111$
On entry, iref has either not been initialized or has been corrupted.
${\mathbf{ifail}}=113$
On entry, iref is too short to use with g05yqf.
${\mathbf{ifail}}=114$
On entry, the specified dimensions are out of sync.
A different number of values have been generated from at least one of the specified dimensions.
${\mathbf{ifail}}=115$
g05yqf can not be used with the Faure generator.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Not applicable.

## 8Parallelism and Performance

g05yqf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g05yqf 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 implementation-specific information.

None.

## 10Example

This example generates a sequence of $10$ values from a Normal distribution with mean $3.1$ and standard deviation $2.1$, from dimensions $3$ to $7$ of an $8$ dimension Sobol sequence.

### 10.1Program Text

Program Text (g05yqfe.f90)

### 10.2Program Data

Program Data (g05yqfe.d)

### 10.3Program Results

Program Results (g05yqfe.r)