NAG FL Interface
g05ynf (quasi_​init_​scrambled)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

g05ynf initializes a scrambled quasi-random generator prior to calling g05yjf, g05ykf or g05ymf. It must be preceded by a call to one of the pseudorandom initialization routines g05kff or g05kgf.

2 Specification

Fortran Interface
Subroutine g05ynf ( genid, stype, idim, iref, liref, iskip, nsdigi, state, ifail)
Integer, Intent (In) :: genid, stype, idim, liref, iskip, nsdigi
Integer, Intent (Inout) :: iref(liref), state(*), ifail
C Header Interface
#include <nag.h>
void  g05ynf_ (const Integer *genid, const Integer *stype, const Integer *idim, Integer iref[], const Integer *liref, const Integer *iskip, const Integer *nsdigi, Integer state[], Integer *ifail)
The routine may be called by the names g05ynf or nagf_rand_quasi_init_scrambled.

3 Description

g05ynf 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 routines g05yjf, g05ykf or g05ymf.
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 genid=1. 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 genid=2 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 genid=3.

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: genid Integer Input
On entry: must identify the quasi-random generator to use.
genid=1
Sobol generator.
genid=2
Sobol (A659) generator.
genid=3
Niederreiter generator.
Constraint: genid=1, 2 or 3.
2: stype Integer Input
On entry: must identify the scrambling method to use.
stype=0
No scrambling. This is equivalent to calling g05ylf.
stype=1
Owen like scrambling.
stype=2
Faure–Tezuka scrambling.
stype=3
Owen and Faure–Tezuka scrambling.
Constraint: stype=0, 1, 2 or 3.
3: idim Integer Input
On entry: the number of dimensions required.
Constraints:
  • if genid=1, 1idim50000;
  • if genid=2, 1idim50000;
  • if genid=3, 1idim318.
4: iref(liref) Integer array Communication Array
On exit: contains initialization information for use by the generator routines g05yjf, g05ykf and g05ymf. iref must not be altered in any way between initialization and calls of the generator routines.
5: liref Integer Input
On entry: the dimension of the array iref as declared in the (sub)program from which g05ynf is called.
Constraint: liref33×idim+7.
6: iskip Integer Input
On entry: the number of terms of the sequence to skip on initialization for the Sobol and Niederreiter generators.
Constraint: 0iskip230.
7: nsdigi Integer Input
On entry: controls the number of digits (bits) to scramble when genid=1 or 2, otherwise nsdigi is ignored. If nsdigi<1 or nsdigi>30 then all the digits are scrambled.
8: state(*) Integer array Communication Array
Note: the actual argument supplied must be the array state supplied to the initialization routines g05kff or g05kgf.
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: 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 -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry 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:
ifail=1
On entry, genid=value.
Constraint: 1genidvalue.
ifail=2
On entry, stype=value.
Constraint: 0stype3.
ifail=3
On entry, idim=value.
Constraint: 1idimvalue.
ifail=5
On entry, liref=value.
Constraint: liref32×idim+7.
ifail=6
On entry, iskip=value.
Constraint: 0iskip230.
ifail=8
On entry, state vector has been corrupted or not initialized.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
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.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
g05ynf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
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.

9 Further Comments

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

10 Example

This example calls g05kff, g05ymf and g05ynf 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.

10.1 Program Text

Program Text (g05ynfe.f90)

10.2 Program Data

Program Data (g05ynfe.d)

10.3 Program Results

Program Results (g05ynfe.r)