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_normal (g05yj)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


nag_rand_quasi_normal (g05yj) generates a quasi-random sequence from a Normal (Gaussian) 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).


[quas, iref, ifail] = g05yj(xmean, std, n, iref)
[quas, iref, ifail] = nag_rand_quasi_normal(xmean, std, n, iref)


nag_rand_quasi_normal (g05yj) generates a quasi-random sequence from a Normal distribution by first generating a uniform quasi-random 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 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).


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


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 Normal distribution.
2:     stdidim – double array
Specifies, for each dimension, the standard deviation of the 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


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:
On entry, incorrect initialization has been detected.
On entry,n<1.
A standard deviation is negative.
There have been too many calls to the generator.
An unexpected error has been triggered by this routine. Please contact NAG.
Your licence key may have expired or may not have been installed correctly.
Dynamic memory allocation failed.


Not applicable.

Further Comments



This example calls nag_rand_quasi_init (g05yl) to initialize the generator and then nag_rand_quasi_normal (g05yj) to generate a sequence of five four-dimensional variates.
function g05yj_example

fprintf('g05yj 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( ...

% Number of variates
n = int64(5);

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

% Generate N values for the normal distribution
[quasi, iref, ifail] = g05yj( ...
                              xmean, std, n, iref);


g05yj example results

    1.5820    2.2448    0.9154    3.0722
    2.8768    1.6057    3.7341    5.4521
    0.9240    3.0223    2.3828    3.8154
    0.6004    1.9290    1.9355    3.4806
    2.0141    3.9061    3.3680    4.8479

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