|
NAG[g05yac] NAG[nag_quasi_random_uniform] - Multi-dimensional quasi-random number generator with a uniform probability distribution
|
|
Calling Sequence
g05yac(state, sequence_type, iskip, quasi, gf, 'idim'=idim, 'fail'=fail)
nag_quasi_random_uniform(. . .)
Parameters
|
state - String;
|
|
|
On entry: the type of operation to perform.
|
|
The first call for initialization, and there is no output via array quasi.
|
|
The sequence has been initialized by a prior call to nag_quasi_random_uniform (g05yac) with . Random numbers are output via array quasi.
|
|
The final call to release memory, and no further random numbers are required for output via array quasi.
|
|
Constraint: "Nag_QuasiRandom_Init", "Nag_QuasiRandom_Cont" or "Nag_QuasiRandom_Finish". .
|
|
|
sequence_type - String;
|
|
|
On entry: the type of sequence to generate.
|
|
A Sobol sequence.
|
|
A Neiderreiter sequence.
|
|
A Faure sequence.
|
|
Constraint: "Nag_QuasiRandom_Sobol", "Nag_QuasiRandom_Nied" or "Nag_QuasiRandom_Faure". .
|
|
|
iskip - integer;
|
|
|
On entry: the number of terms in the sequence to skip on initialization.
|
|
All the terms of the sequence are generated.
|
|
If , iskip is not referenced.
|
|
|
quasi - Vector(1..idim, datatype=float[8]);
|
|
|
|
gf - Vector;
|
|
|
On entry/exit: A Maple Vector, which should be generated using NAG[Nag_QuasiRandom], corresponding to the Nag_QuasiRandom structure.
|
|
|
'idim'=idim - integer; (optional)
|
|
|
On entry: the number of dimensions required.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
To generate multi-dimensional quasi-random sequences with a uniform probability distribution.
|
|
Description
|
|
Low discrepancy (quasi-random) sequences are used in numerical integration, simulation and optimization. Like pseudo-random numbers they are uniformly distributed but they are not statistically independent, rather they are designed to give more even distribution in multidimensional space (uniformity). Therefore they are often more efficient than pseudo-random numbers in multidimensional Monte Carlo methods.
nag_quasi_random_uniform (g05yac) generates a set of points with high uniformity in the -dimensional unit cube . One measure of the uniformity is the discrepancy which is defined as follows:
|
with volume . Then the discrepancy of the points is
|
|
The discrepancy of the first terms of such a sequence has the form
|
|
The principal aim in the construction of low-discrepancy sequences is to find sequences of points in with a bound of this form where the constant is as small as possible.
|
nag_quasi_random_uniform (g05yac) generates the low-discrepancy sequences proposed by Sobol, Faure and Neiderreiter. Here, both the Sobol and Neiderreiter sequences are implemented in binary arithmetic and make use of the bitwise exclusive-or operation, where possible (see the Users' Note).
|
|
Error Indicators and Warnings
|
|
"NE_BAD_PARAM"
On entry, argument had an illegal value.
"NE_INITIALIZATION"
Incorrect initialization.
"NE_INT"
On entry, . Constraint: .
On entry, value of skip too large: .
"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 consult NAG for assistance.
"NE_TOO_MANY_CALLS"
Too many calls to generator.
|
|
Further Comments
|
|
The maximum length of the generated sequences is , this should be adequate for practical purposes. In the case of the Neiderreiter generator nag_quasi_random_uniform (g05yac) jumps to the appropriate starting point, while for the Sobol generator it simply steps through the sequence. In consequence the Sobol generator with large values of iskip will take a significant amount of time.
|
|
|
Examples
|
|
>
|
state := "Nag_QuasiRandom_Init":
sequence_type := "Nag_QuasiRandom_Faure":
iskip := 0:
idim := 22:
gf := NAG:-Nag_QuasiRandom():
quasi := Vector(idim, datatype=float[8]):
NAG:-g05yac(state, sequence_type, iskip, quasi, gf, 'idim' = idim) ;
# 55sec on a fast P4, without a Try for each call to g05yac.
# How bad is this? Some copying overhead might be avoided, with effort.
ntimes := 50000:
state := "Nag_QuasiRandom_Cont":
thesum := 0.0:
for i from 1 to ntimes do
NAG:-g05yac(state, sequence_type, iskip, quasi, gf, 'idim' = idim):
#):
thesum := thesum + mul(abs(quasi[j]*4.0-2.0),j=1..idim):
end do:
vsbl := thesum/ntimes:
state := "Nag_QuasiRandom_Finish":
NAG:-g05yac(state, sequence_type, iskip, quasi, gf, 'idim' = idim) ;
# No need to free quasi
NAG:-FreeOptions(gf) ;
|
|
|
See Also
|
|
Brately 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) Implementation and Relative Efficiency of Quasirandom Sequence Generators ACM Trans. Math. Software 12 (4) 362–376
g05 Chapter Introduction.
NAG Toolbox Overview.
NAG Web Site.
|
|