g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

NAG Library Function Documentnag_quasi_init_scrambled (g05ync)

1  Purpose

nag_quasi_init_scrambled (g05ync) initializes a scrambled quasi-random generator prior to calling nag_quasi_rand_normal (g05yjc), nag_quasi_rand_lognormal (g05ykc) or nag_quasi_rand_uniform (g05ymc). It must be preceded by a call to one of the pseudorandom initialization functions nag_rand_init_repeatable (g05kfc) or nag_rand_init_nonrepeatable (g05kgc).

2  Specification

 #include #include
 void nag_quasi_init_scrambled (Nag_QuasiRandom_Sequence genid, Nag_QuasiRandom_Scrambling stype, Integer idim, Integer iref[], Integer liref, Integer iskip, Integer nsdigi, Integer state[], NagError *fail)

3  Description

nag_quasi_init_scrambled (g05ync) selects a quasi-random number generator through the input value of genid, a method of scrambling through the input value of stype and initializes the iref communication array for use in the functions nag_quasi_rand_normal (g05yjc), nag_quasi_rand_lognormal (g05ykc) or nag_quasi_rand_uniform (g05ymc).
Scrambled quasi-random sequences are an extension of standard quasi-random sequences that attempt to eliminate the bias inherent in a quasi-random sequence whilst retaining the low-discrepancy properties. The use of a scrambled sequence allows error estimation of Monte–Carlo results by performing a number of iterates and computing the variance of the results.
This implementation of scrambled quasi-random sequences is based on TOMS Algorithm 823 and details can be found in the accompanying paper, Hong and Hickernell (2003). Three methods of scrambling are supplied; the first a restricted form of Owen's scrambling (Owen (1995)), the second based on the method of Faure and Tezuka (2000) and the last method combines the first two.
Scrambled versions of the Niederreiter sequence and two sets of Sobol sequences are provided. The first Sobol sequence is obtained using ${\mathbf{genid}}=\mathrm{Nag_QuasiRandom_Sobol}$. The first 10000 direction numbers for this sequence are based on the work of Joe and Kuo (2008). For dimensions greater than 10000 the direction numbers are randomly generated using the pseudorandom generator specified in state (see Jäckel (2002) for details). The second Sobol sequence is obtained using ${\mathbf{genid}}=\mathrm{Nag_QuasiRandom_SobolA659}$ and referred to in the documentation as ‘Sobol (A659)’. The first 1111 direction numbers for this sequence are based on Algorithm 659 of Bratley and Fox (1988) with the extension proposed by Joe and Kuo (2003). For dimensions greater than 1111 the direction numbers are once again randomly generated. The Niederreiter sequence is obtained by setting ${\mathbf{genid}}=\mathrm{Nag_QuasiRandom_Nied}$.

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
Faure H and Tezuka S (2000) Another random scrambling of digital (t,s)-sequences Monte Carlo and Quasi-Monte Carlo Methods Springer-Verlag, Berlin, Germany (eds K T Fang, F J Hickernell and H Niederreiter)
Hong H S and Hickernell F J (2003) Algorithm 823: implementing scrambled digital sequences ACM Trans. Math. Software 29:2 95–109
Jäckel P (2002) Monte Carlo Methods in Finance Wiley Finance Series, John Wiley and Sons, England
Joe S and Kuo F Y (2003) Remark on Algorithm 659: implementing Sobol's quasirandom sequence generator ACM Trans. Math. Software (TOMS) 29 49–57
Joe S and Kuo F Y (2008) Constructing Sobol sequences with better two-dimensional projections SIAM J. Sci. Comput. 30 2635–2654
Niederreiter H (1988) Low-discrepancy and low dispersion sequences Journal of Number Theory 30 51–70
Owen A B (1995) Randomly permuted (t,m,s)-nets and (t,s)-sequences Monte Carlo and Quasi-Monte Carlo Methods in Scientific Computing, Lecture Notes in Statistics 106 Springer-Verlag, New York, NY 299–317 (eds H Niederreiter and P J-S Shiue)

5  Arguments

1:     genidNag_QuasiRandom_SequenceInput
On entry: must identify the quasi-random generator to use.
${\mathbf{genid}}=\mathrm{Nag_QuasiRandom_Sobol}$
Sobol generator.
${\mathbf{genid}}=\mathrm{Nag_QuasiRandom_SobolA659}$
Sobol (A659) generator.
${\mathbf{genid}}=\mathrm{Nag_QuasiRandom_Nied}$
Niederreiter generator.
Constraint: ${\mathbf{genid}}=\mathrm{Nag_QuasiRandom_Sobol}$, $\mathrm{Nag_QuasiRandom_SobolA659}$ or $\mathrm{Nag_QuasiRandom_Nied}$.
2:     stypeNag_QuasiRandom_ScramblingInput
On entry: must identify the scrambling method to use.
${\mathbf{stype}}=\mathrm{Nag_NoScrambling}$
No scrambling. This is equivalent to calling nag_quasi_init (g05ylc).
${\mathbf{stype}}=\mathrm{Nag_OwenLike}$
Owen like scrambling.
${\mathbf{stype}}=\mathrm{Nag_FaureTezuka}$
Faure–Tezuka scrambling.
${\mathbf{stype}}=\mathrm{Nag_OwenFaureTezuka}$
Owen and Faure–Tezuka scrambling.
Constraint: ${\mathbf{stype}}=\mathrm{Nag_NoScrambling}$, $\mathrm{Nag_OwenLike}$, $\mathrm{Nag_FaureTezuka}$ or $\mathrm{Nag_OwenFaureTezuka}$.
3:     idimIntegerInput
On entry: the number of dimensions required.
Constraints:
• if ${\mathbf{genid}}=\mathrm{Nag_QuasiRandom_Sobol}$, $1\le {\mathbf{idim}}\le 50000$;
• if ${\mathbf{genid}}=\mathrm{Nag_QuasiRandom_SobolA659}$, $1\le {\mathbf{idim}}\le 50000$;
• if ${\mathbf{genid}}=\mathrm{Nag_QuasiRandom_Nied}$, $1\le {\mathbf{idim}}\le 318$.
4:     iref[liref]IntegerCommunication Array
On exit: contains initialization information for use by the generator functions nag_quasi_rand_normal (g05yjc), nag_quasi_rand_lognormal (g05ykc) and nag_quasi_rand_uniform (g05ymc). iref must not be altered in any way between initialization and calls of the generator functions.
5:     lirefIntegerInput
On entry: the dimension of the array iref.
Constraint: ${\mathbf{liref}}\ge 32×{\mathbf{idim}}+7$.
6:     iskipIntegerInput
On entry: the number of terms of the sequence to skip on initialization for the Sobol and Niederreiter generators.
Constraint: $0\le {\mathbf{iskip}}\le {2}^{30}$.
7:     nsdigiIntegerInput
On entry: controls the number of digits (bits) to scramble when ${\mathbf{genid}}=\mathrm{Nag_QuasiRandom_Sobol}$ or $\mathrm{Nag_QuasiRandom_SobolA659}$, otherwise nsdigi is ignored. If ${\mathbf{nsdigi}}<1$ or ${\mathbf{nsdigi}}>30$ then all the digits are scrambled.
8:     state[$\mathit{dim}$]IntegerCommunication Array
Note: the actual argument supplied must be the array state supplied to the initialization functions nag_rand_init_repeatable (g05kfc) or nag_rand_init_nonrepeatable (g05kgc).
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
9:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{idim}}=〈\mathit{\text{value}}〉$.
Constraint: $1\le {\mathbf{idim}}\le 〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{iskip}}=〈\mathit{\text{value}}〉$.
Constraint: $0\le {\mathbf{iskip}}\le {2}^{30}$.
On entry, ${\mathbf{liref}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{liref}}\ge 32×{\mathbf{idim}}+7$.
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.
NE_INVALID_STATE
On entry, state vector has been corrupted or not initialized.

7  Accuracy

Not applicable.

The additional computational cost in using a scrambled quasi-random sequence over a non-scrambled one comes entirely during the initialization. Once nag_quasi_init_scrambled (g05ync) has been called the computational cost of generating a scrambled sequence and a non-scrambled one is identical.

9  Example

This example calls nag_rand_init_repeatable (g05kfc), nag_quasi_rand_uniform (g05ymc) and nag_quasi_init_scrambled (g05ync) to estimate the value of the integral
 $∫01 ⋯ ∫01 ∏ i=1 s 4xi-2 dx1, dx2, …, dxs = 1 ,$
where $s$, the number of dimensions, is set to $8$.

9.1  Program Text

Program Text (g05ynce.c)

None.

9.3  Program Results

Program Results (g05ynce.r)