hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_rand_quasi_lognormal (g05yk)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_rand_quasi_lognormal (g05yk) generates a quasi-random sequence from a log-normal distribution. It must be preceded by a call to one of the initialization functions nag_rand_quasi_init (g05yl) or nag_rand_quasi_init_scrambled (g05yn).

Syntax

[quas, iref, ifail] = g05yk(xmean, std, n, iref)
[quas, iref, ifail] = nag_rand_quasi_lognormal(xmean, std, n, iref)

Description

nag_rand_quasi_lognormal (g05yk) generates a quasi-random sequence from a log-normal distribution by first generating a uniform quasi-random sequence 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 nag_rand_quasi_init_scrambled (g05yn) was used then the underlying uniform sequence is first scrambled prior to being transformed (see Description in nag_rand_quasi_init_scrambled (g05yn) for details).

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

Parameters

Note: the following variables are used in the parameter descriptions:

Compulsory Input Parameters

1:     xmeanidim – double array
Specifies, for each dimension, the mean of the underlying Normal distribution.
Constraint: xmeani - logx02am -10.0× stdi , for i=1,2,,idim.
2:     stdidim – double array
Specifies, for each dimension, the standard deviation of the underlying Normal distribution.
Constraint: stdi0.0, for i=1,2,,idim.
3:     n int64int32nag_int scalar
The number of quasi-random numbers required.
Constraint: n0 and n+previous number of generated values231-1.
4:     irefliref int64int32nag_int array
Contains information on the current state of the sequence.

Optional Input Parameters

None.

Output Parameters

1:     quasnidim – double array
Contains the n quasi-random numbers of dimension idim.
2:     irefliref int64int32nag_int array
Contains updated information on the state of the sequence.
3:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
On entry, incorrect initialization has been detected.
   ifail=2
On entry,n<1.
   ifail=3
On entry,at least one element of xmean is too large.
   ifail=4
There have been too many calls to the generator.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Not applicable.

Further Comments

None.

Example

This example calls nag_rand_quasi_init (g05yl) to initialize the generator and then nag_rand_quasi_lognormal (g05yk) to produce a sequence of five four-dimensional quasi-random numbers variates.
function g05yk_example


fprintf('g05yk example results\n\n');

% Initialize the Sobol generator, skipping some variates
iskip = int64(1000);
idim  = int64(4);
genid = int64(1);
% Initialize the Sobol generator
[iref, ifail] = g05yl( ...
                       genid,idim,iskip);

% Number of variates
n = int64(5);

% Parameters
xmean = [1; 2; 3; 4];
std = [1; 1; 1; 1];

% Generate n values from the log-normal distribution
[quasi, iref, ifail] = g05yk( ...
                              xmean, std, n, iref);

disp('Variates');
disp(quasi);


g05yk example results

Variates
    4.8648    9.4382    2.4979   21.5895
   17.7572    4.9813   41.8501  233.2386
    2.5195   20.5384   10.8353   45.3933
    1.8229    6.8823    6.9276   32.4808
    7.4938   49.7034   29.0198  127.4745


PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015