PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_rand_quasi_uniform (g05ym)
Purpose
nag_rand_quasi_uniform (g05ym) generates a uniformly distributed low-discrepancy sequence as proposed by Sobol, Faure or Niederreiter. 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
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 24: |
rcord was made optional |
Description
Low discrepancy (quasi-random) sequences are used in numerical integration, simulation and optimization. Like pseudorandom 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 pseudorandom numbers in multidimensional Monte–Carlo methods.
nag_rand_quasi_uniform (g05ym) generates a set of points with high uniformity in the -dimensional unit cube .
Let
be a subset of
and define the counting function
as the number of points
. For each
, let
be the rectangular
-dimensional region
with volume
. Then one measure of the uniformity of the points
is the discrepancy:
which 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.
The type of low-discrepancy sequence generated by
nag_rand_quasi_uniform (g05ym) depends on the initialization function called and can include those proposed by Sobol, Faure or Niederreiter. If the initialization function
nag_rand_quasi_init_scrambled (g05yn) was used then the sequence will be scrambled (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
Parameters
Note: the following variables are used in the parameter descriptions:
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
The number of quasi-random numbers required.
Constraint:
and .
- 2:
– int64int32nag_int array
-
Contains information on the current state of the sequence.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
Default:
The order in which the generated values are returned.
Constraint:
or .
Output Parameters
- 1:
– double array
-
Contains the
n quasi-random numbers of dimension
idim.
If , holds the th value for the th dimension.
If , holds the th value for the th dimension.
- 2:
– int64int32nag_int array
-
Contains updated information on the state of the sequence.
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
Constraint: .
On entry, value of
n would result in too many calls to the generator.
-
-
Constraint: or .
-
-
Constraint: if , .
Constraint: if , .
-
-
On entry,
iref has either not been initialized or has been corrupted.
-
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.
Accuracy
Not applicable.
Further Comments
None.
Example
This example calls
nag_rand_quasi_init (g05yl) and
nag_rand_quasi_uniform (g05ym) to estimate the value of the integral
In this example the number of dimensions is set to .
Open in the MATLAB editor:
g05ym_example
function g05ym_example
fprintf('g05ym example results\n\n');
iskip = int64(1000);
idim = int64(8);
genid = int64(1);
[iref, ifail] = g05yl( ...
genid,idim,iskip);
n = int64(200);
[quas, iref, ifail] = g05ym( ...
n, iref);
p(1:n) = prod(abs(4*quas(1:idim,:)-2));
fsum = sum(p);
vsbl = fsum/double(n);
fprintf('Value of integral = %8.4f\n\n', vsbl);
fprintf('First 10 variates\n');
for i = 1:10
fprintf(' %3d', i);
fprintf(' %7.4f', quas(1:idim,i));
fprintf('\n');
end
g05ym example results
Value of integral = 1.0410
First 10 variates
1 0.7197 0.5967 0.0186 0.1768 0.7803 0.4072 0.5459 0.3994
2 0.9697 0.3467 0.7686 0.9268 0.5303 0.1572 0.2959 0.1494
3 0.4697 0.8467 0.2686 0.4268 0.0303 0.6572 0.7959 0.6494
4 0.3447 0.4717 0.1436 0.3018 0.1553 0.7822 0.4209 0.0244
5 0.8447 0.9717 0.6436 0.8018 0.6553 0.2822 0.9209 0.5244
6 0.5947 0.2217 0.3936 0.0518 0.9053 0.0322 0.1709 0.7744
7 0.0947 0.7217 0.8936 0.5518 0.4053 0.5322 0.6709 0.2744
8 0.0635 0.1904 0.0498 0.4580 0.6240 0.2510 0.9521 0.8057
9 0.5635 0.6904 0.5498 0.9580 0.1240 0.7510 0.4521 0.3057
10 0.8135 0.4404 0.2998 0.2080 0.3740 0.5010 0.7021 0.0557
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015