nag_quasi_rand_uniform (g05ymc) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_quasi_rand_uniform (g05ymc)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_quasi_rand_uniform (g05ymc) 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_quasi_init (g05ylc) or nag_quasi_init_scrambled (g05ync).

2  Specification

#include <nag.h>
#include <nagg05.h>
void  nag_quasi_rand_uniform (Nag_OrderType order, Integer n, double quas[], Integer pdquas, Integer iref[], NagError *fail)

3  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_quasi_rand_uniform (g05ymc) generates a set of points x1,x2,,xN with high uniformity in the S-dimensional unit cube IS=0,1S.
Let G be a subset of IS and define the counting function SNG as the number of points xiG. For each x=x1,x2,,xSIS, let Gx be the rectangular S-dimensional region
G x = 0, x 1 × 0, x 2 ×× 0, x S  
with volume x1,x2,,xS. Then one measure of the uniformity of the points x1,x2,,xN is the discrepancy:
DN* x1,x2,,xN = sup xIS SN Gx - N x1 , x2 , , xS .  
which has the form
DN*x1,x2,,xNCSlogNS+OlogNS-1  for all  N2.  
The principal aim in the construction of low-discrepancy sequences is to find sequences of points in IS with a bound of this form where the constant CS is as small as possible.
The type of low-discrepancy sequence generated by nag_quasi_rand_uniform (g05ymc) depends on the initialization function called and can include those proposed by Sobol, Faure or Niederreiter. If the initialization function nag_quasi_init_scrambled (g05ync) was used then the sequence will be scrambled (see Section 3 in nag_quasi_init_scrambled (g05ync) for details).

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
Fox B L (1986) Algorithm 647: implementation and relative efficiency of quasirandom sequence generators ACM Trans. Math. Software 12(4) 362–376

5  Arguments

Note: the following variables are used in the parameter descriptions:
1:     order Nag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by order=Nag_RowMajor. See Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: order=Nag_RowMajor or Nag_ColMajor.
2:     n IntegerInput
On entry: the number of quasi-random numbers required.
Constraint: n0 and n+previous number of generated values231-1.
3:     quas[pdquas×tdquas] doubleOutput
Note: the dimension, dim, of the array quas must be at least pdquas×tdquas.
Where QUASi,j appears in this document, it refers to the array element
  • quas[j-1×pdquas+i-1] when order=Nag_ColMajor;
  • quas[i-1×pdquas+j-1] when order=Nag_RowMajor.
On exit: QUASi,j holds the ith value for the jth dimension.
4:     pdquas IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array quas.
Constraints:
  • if order=Nag_RowMajor, pdquasidim;
  • if order=Nag_ColMajor, pdquasn.
5:     iref[liref] IntegerCommunication Array
On entry: contains information on the current state of the sequence.
On exit: contains updated information on the state of the sequence.
6:     fail NagError *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.
See Section 3.2.1.2 in the Essential Introduction for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INITIALIZATION
On entry, iref has either not been initialized or has been corrupted.
NE_INT
On entry, n=value.
Constraint: n0.
NE_INT_2
On entry, pdquas=value, idim=value.
Constraint: if order=Nag_RowMajor, pdquasidim.
On entry, pdquas=value and n=value.
Constraint: if order=Nag_ColMajor, pdquasn.
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.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 3.6.6 in the Essential Introduction for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 3.6.5 in the Essential Introduction for further information.
NE_TOO_MANY_CALLS
On entry, value of n would result in too many calls to the generator: n=value, generator has previously been called value times.

7  Accuracy

Not applicable.

8  Parallelism and Performance

nag_quasi_rand_uniform (g05ymc) 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 function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
The Sobol, Sobol (A659) and Niederreiter quasi-random number generators in nag_quasi_rand_uniform (g05ymc) have been parallelized, but require quite large problem sizes to see any significant performance gain. Parallelism is only enabled when order=Nag_ColMajor. The Faure generator is serial.

9  Further Comments

None.

10  Example

This example calls nag_quasi_init (g05ylc) and nag_quasi_rand_uniform (g05ymc) to estimate the value of the integral
01 01 i=1 s 4xi-2 dx1, dx2, , dxs = 1 .  
In this example the number of dimensions S is set to 8.

10.1  Program Text

Program Text (g05ymce.c)

10.2  Program Data

None.

10.3  Program Results

Program Results (g05ymce.r)


nag_quasi_rand_uniform (g05ymc) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2015