# NAG CL Interfaceg05yrc (quasi_​lognormal_​bydim)

Settings help

CL Name Style:

## 1Purpose

g05yrc generates a quasi-random sequence from a log-normal distribution. It must be preceded by a call to one of the initialization functions g05ylc or g05ync.

## 2Specification

 #include
 void g05yrc (Nag_OrderType order, Integer n, const double xmean[], const double std[], Integer fdim, Integer ldim, double quas[], Integer pdquas, Integer iref[], NagError *fail)
The function may be called by the names: g05yrc or nag_rand_quasi_lognormal_bydim.

## 3Description

g05yrc generates a quasi-random sequence, for a specified subset of dimensions, from a log-normal distribution by first generating a uniform quasi-random sequence, for the specified subset of dimensions, which is then transformed into a log-normal sequence using the exponential of the inverse of the Normal CDF. The type of uniform sequence used depends on the initialization function called and can include the low-discrepancy sequences proposed by Sobol, Faure or Niederreiter. If the initialization function g05ync was used then the underlying uniform sequence is first scrambled prior to being transformed (see Section 3 in g05ync 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 g05ylc or g05ync;
• $\mathit{liref}={\mathbf{liref}}$, the length of iref as supplied to the initialization functions g05ylc or g05ync.
1: $\mathbf{order}$Nag_OrderType Input
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
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[\mathit{dim}\right]$const double Input
On entry: specifies, for each dimension, the mean of the underlying Normal distribution.
Constraint: $|{\mathbf{xmean}}\left[\mathit{i}-1\right]|\le |-\mathrm{log}\left({\mathbf{nag_real_safe_small_number}}\right)-10.0×{\mathbf{std}}\left[\mathit{i}-1\right]|$, for $\mathit{i}=1,2,\dots ,\mathit{idim}$.
4: $\mathbf{std}\left[\mathit{dim}\right]$const double Input
On entry: specifies, for each dimension, the standard deviation of the underlying Normal distribution.
Constraint: ${\mathbf{std}}\left[\mathit{i}-1\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[\mathit{dim}\right]$double Output
Note: where ${\mathbf{QUAS}}\left(i,k\right)$ appears in this document, it refers to the array element
• ${\mathbf{quas}}\left[\left(k-1\right)×{\mathbf{pdquas}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{quas}}\left[\left(i-1\right)×{\mathbf{pdquas}}+k-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
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{order}}=\mathrm{Nag_ColMajor}$,
• ${\mathbf{QUAS}}\left(k,\mathit{i}\right)$, if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
8: $\mathbf{pdquas}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array quas.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdquas}}\ge {\mathbf{n}}$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdquas}}\ge {\mathbf{ldim}}-{\mathbf{fdim}}+1$.
9: $\mathbf{iref}\left[\mathit{dim}\right]$Integer Communication Array
Note: the dimension, dim, 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{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_ARRAY_SIZE
On entry, ${\mathbf{pdquas}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ldim}}-{\mathbf{fdim}}+1=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdquas}}\ge {\mathbf{ldim}}-{\mathbf{fdim}}+1$.
On entry, ${\mathbf{pdquas}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdquas}}\ge {\mathbf{n}}$.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INITIALIZATION
g05yrc can not be used with the Faure generator.
On entry, iref has either not been initialized or has been corrupted.
On entry, iref is too short to use with g05yrc.
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.
NE_INT
On entry, ${\mathbf{ldim}}=⟨\mathit{\text{value}}⟩$ and $\mathit{idim}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldim}}\le \mathit{idim}$
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
NE_INT_2
On entry, ${\mathbf{fdim}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ldim}}=⟨\mathit{\text{value}}⟩$.
Constraint: $1\le {\mathbf{fdim}}\le {\mathbf{ldim}}$
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_REAL_ARRAY
On entry, $i=⟨\mathit{\text{value}}⟩$ and ${\mathbf{std}}\left[i-1\right]=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{std}}\left[i-1\right]\ge 0$.
On entry, $i=⟨\mathit{\text{value}}⟩$ and ${\mathbf{xmean}}\left[i-1\right]=⟨\mathit{\text{value}}⟩$.
Constraint: $|{\mathbf{xmean}}\left[i-1\right]|\le ⟨\mathit{\text{value}}⟩$.
NE_TOO_MANY_CALLS
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.

Not applicable.

## 8Parallelism and Performance

g05yrc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g05yrc 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 function. 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 log-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 (g05yrce.c)

### 10.2Program Data

Program Data (g05yrce.d)

### 10.3Program Results

Program Results (g05yrce.r)