hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox Chapter Introduction

G05 — Random Number Generators

Scope of the Chapter

This chapter is concerned with the generation of sequences of independent pseudorandom and quasi-random numbers from various distributions, and models.

Background to the Problems

Pseudorandom Numbers

A sequence of pseudorandom numbers is a sequence of numbers generated in some systematic way such that they are independent and statistically indistinguishable from a truly random sequence. A pseudorandom number generator (PRNG) is a mathematical algorithm that, given an initial state, produces a sequence of pseudorandom numbers. A PRNG has several advantages over a true random number generator in that the generated sequence is repeatable, has known mathematical properties and can be implemented without needing any specialist hardware. Many books on statistics and computer science have good introductions to PRNGs, for example Knuth (1981) or Banks (1998).
PRNGs can be split into base generators, and distributional generators. Within the context of this document a base generator is defined as a PRNG that produces a sequence (or stream) of variates (or values) uniformly distributed over the interval (0,1)(0,1). Depending on the algorithm being considered, this interval may be open, closed or half-closed. A distribution generator is a function that takes variates generated from a base generator and transforms them into variates from a specified distribution, for example a uniform, Gaussian (Normal) or gamma distribution.
The period (or cycle length) of a base generator is defined as the maximum number of values that can be generated before the sequence starts to repeat. The initial state of the base generator is often called the seed.
There are six base generators currently available in the NAG Toolbox, these are; a basic linear congruential generator (LCG) (referred to as the NAG basic generator) (see Knuth (1981)), two sets of Wichmann–Hill generators (see Maclaren (1989) and Wichmann and Hill (2006)), the Mersenne Twister (see Matsumoto and Nishimura (1998)), the ACORN generator (see Wikramaratna (1989)) and L'Ecuyer generator (see L'Ecuyer and Simard (2002)).

NAG Basic Generator

The NAG basic generator is a linear congruential generator (LCG) and, like all linear congruential generators, has the form:
xi = a1 xi1  mod  m1 ,
ui = (xi)/(m1) ,
xi = a1 xi-1  mod  m1 , ui = xi m1 ,
where the uiui, for i = 1,2,i=1,2,, form the required sequence.
The NAG basic generator uses a1 = 1313a1=1313 and m1 = 259m1=259, which gives a period of approximately 257257.
This generator has been part of the NAG Library since Mark 6 and as such has been widely used. It suffers from no known problems, other than those due to the lattice structure inherent in all linear congruential generators, and, even though the period is relatively short compared to many of the newer generators, it is sufficiently large for many practical problems.
The performance of the NAG basic generator has been analysed by the Spectral Test, see Section 3.3.4 of Knuth (1981), yielding the following results in the notation of Knuth (1981).
nn νnνn Upper bound for νnνn
22 3.44 × 1083.44×108 4.08 × 1084.08×108
33 4.29 × 1054.29×105 5.88 × 1055.88×105
44 1.72 × 1041.72×104 2.32 × 1042.32×104
55 1.92 × 1031.92×103 3.33 × 1033.33×103
66 593593 939939
77 198198 380380
88 108108 197197
99 6767 120120
The right-hand column gives an upper bound for the values of νnνn attainable by any multiplicative congruential generator working modulo 259259.
An informal interpretation of the quantities νnνn is that consecutive nn-tuples are statistically uncorrelated to an accuracy of 1 / νn1/νn. This is a theoretical result; in practice the degree of randomness is usually much greater than the above figures might support. More details are given in Knuth (1981), and in the references cited therein.
Note that the achievable accuracy drops rapidly as the number of dimensions increases. This is a property of all multiplicative congruential generators and is the reason why very long periods are needed even for samples of only a few random numbers.

Wichmann–Hill I Generator

This series of Wichmann–Hill base generators (see Maclaren (1989)) use a combination of four linear congruential generators and has the form:
wi = a1wi1  mod  m1
xi = a2xi1  mod  m2
yi = a3yi1  mod  m3
zi = a4zi1  mod  m4
ui = ((wi)/(m1) + (xi)/(m2) + (yi)/(m3) + (zi)/(m4))  mod  1 ,
wi=a1wi-1  mod  m1 xi=a2xi-1  mod  m2 yi=a3yi-1  mod  m3 zi=a4zi-1  mod  m4 ui = ( wi m1 + xi m2 + yi m3 + zi m4 )  mod  1 ,
(1)
where the uiui, for i = 1,2,i=1,2,, form the required sequence. The NAG Toolbox implementation includes 273 sets of parameters, aj,mjaj,mj, for j = 1,2,3,4j=1,2,3,4, to choose from.
The constants aiai are in the range 112 to 127 and the constants mjmj are prime numbers in the range 1671890916718909 to 1677697116776971, which are close to 224 = 16777216224=16777216. These constants have been chosen so that each of the resulting 273 generators are essentially independent, all calculations can be carried out in 32-bit integer arithmetic and the generators give good results with the spectral test, see Knuth (1981) and Maclaren (1989). The period of each of these generators would be at least 292292 if it were not for common factors between (m11)(m1-1), (m21)(m2-1), (m31)(m3-1) and (m41)(m4-1). However, each generator should still have a period of at least 280280. Further discussion of the properties of these generators is given in Maclaren (1989).

Wichmann–Hill II Generator

This Wichmann–Hill base generator (see Wichmann and Hill (2006)) is of the same form as that described in Section [Wichmann–Hill I Generator], i.e., a combination of four linear congruential generators. In this case a1 = 11600a1=11600, m1 = 2147483579m1=2147483579, a2 = 47003a2=47003, m2 = 2147483543m2=2147483543, a3 = 23000a3=23000, m3 = 2147483423m3=2147483423, a4 = 33000a4=33000, m4 = 2147483123m4=2147483123.
Unlike in the original Wichmann–Hill generator, these values are too large to carry out the calculations detailed in (1) using 32-bit integer arithmetic, however, if
wi = 11600 wi1  mod  2147483579
wi = 11600 wi-1  mod  2147483579
then setting
Wi = 11600 (wi1 mod 185127) 10379 (wi1 / 185127)
Wi = 11600 ( wi-1  mod  185127 ) - 10379 ( wi-1 / 185127 )
gives
wi =
{ Wi ​ if ​ Wi ≥ 0 2147483579 + Wi ​ otherwise
wi = { Wi ​ if ​ Wi0 2147483579+Wi ​ otherwise
and WiWi can be calculated in 32-bit integer arithmetic. Similar expressions exist for xixi, yiyi and zizi. The period of this generator is approximately 21212121.
Further details of implementing this algorithm and its properties are given in Wichmann and Hill (2006). This paper also gives some useful guidelines on testing PRNGs.

Mersenne Twister Generator

The Mersenne Twister (see Matsumoto and Nishimura (1998)) is a twisted generalized feedback shift register generator. The algorithm underlying the Mersenne Twister is as follows:
(i) Set some arbitrary initial values x1,x2,,xrx1,x2,,xr, each consisting of ww bits.
(ii) Letting
A =
(0Iw1)
aw aw1a1
,
A= 0 Iw-1 aw aw-1a1 ,
where Iw1Iw-1 is the (w1) × (w1)(w-1)×(w-1) identity matrix and each of the ai,i = 1ai,i=1 to ww take a value of either 00 or 11 (i.e., they can be represented as bits). Define
xi + r = (xi + s(xi (ω : (l + 1)) |xi + 1(l : 1))A) ,
x i+r = ( x i+s ( x i ( ω : (l+1) ) | x i+1 (l:1) ) A ) ,
where xi (ω : (l + 1)) | xi + 1 (l : 1) x i ( ω : (l+1) ) | x i+1 (l:1)  indicates the concatenation of the most significant (upper) wlw-l bits of xixi and the least significant (lower) ll bits of xi + 1xi+1.
(iii) Perform the following operations sequentially:
z = xi + r (xi + rt1)
z = z ((zt2)​ AND ​m1)
z = z ((zt3)​ AND ​m2)
z = z (zt4)
ui + r = z / (2w1) ,
z = xi+r ( xi+r t1 ) z = z ( ( z t2 ) ​ AND ​ m1 ) z = z ( ( z t3 ) ​ AND ​ m2 ) z = z ( z t4 ) u i+r = z/ ( 2w - 1 ) ,
where t1t1, t2t2, t3t3 and t4t4 are integers and m1m1 and m2m2 are bit-masks and ‘tt’ and ‘tt’ represent a tt bit shift right and left respectively,  is bit-wise exclusively or (xor) operation and ‘AND’ is a bit-wise and operation.
The ui + rui+r, for i = 1,2,i=1,2,, form the required sequence. The supplied implementation of the Mersenne Twister uses the following values for the algorithmic constants:
w = 32
a = 0x9908b0 df
l = 31
r = 624
s = 397
t1 = 11
t2 = 7
t3 = 15
t4 = 18
m1 = 0x9d2c5680
m2 = 0xefc60000
w = 32 a = 0x9908b0 df l = 31 r = 624 s = 397 t1 = 11 t2 = 7 t3 = 15 t4 = 18 m1 = 0x9d2c5680 m2 = 0xefc60000
where the notation 0xDD  indicates the bit pattern of the integer whose hexadecimal representation is DD .
This algorithm has a period length of approximately 219,9371219,937-1 and has been shown to be uniformly distributed in 623 dimensions (see Matsumoto and Nishimura (1998)).

ACORN Generator

The ACORN generator is a special case of a multiple recursive generator (see Wikramaratna (1989) and Wikramaratna (2007)). The algorithm underlying ACORN is as follows:
(i) Choose an integer value k1k1.
(ii) Choose an integer value MM, and an integer seed Y0(0)Y0(0), such that 0 < Y0(0) < M0<Y0(0)<M and Y0(0)Y0(0) and MM are relatively prime.
(iii) Choose an arbitrary set of kk initial integer values, Y0(1),Y0(2),,Y0(k)Y0(1),Y0(2),,Y0(k), such that 0 Y0(m) < M0 Y0(m)<M, for all m = 1,2,,km=1,2,,k.
(iv) Perform the following sequentially:
Yi(m) = (Yi(m1) + Yi1(m))  mod  M
Y i (m) = ( Y i (m-1) + Y i-1 (m) )  mod  M
for m = 1,2,,km=1,2,,k.
(v) Set ui = Yi(k) / Mui=Yi(k)/M.
The uiui, for i = 1,2,i=1,2,, then form a pseudorandom sequence, with ui [0,1)ui [0,1), for all ii.
Although you can choose any value for kk, MM, Y0(0)Y0(0) and the Y0(m)Y0(m), within the constraints mentioned in (i) to (iii) above, it is recommended that k10k10, MM is chosen to be a large power of two with M260M260 and Y0(0)Y0(0) is chosen to be odd.
The period of the ACORN generator, with the modulus MM equal to a power of two, and an odd value for Y0(0)Y0(0) has been shown to be an integer multiple of MM (see Wikramaratna (1992)). Therefore, increasing MM will give a series with a longer period.

L'Ecuyer MRG32k3a Combined Recursive Generator

The base generator L'Ecuyer MRG32k3a (see L'Ecuyer and Simard (2002)) combines two multiple recursive generators:
xi = ( a11 xi1 + a12 xi2 + a13 xi3 )  mod  m1
yi = ( a21 yi1 + a22 yi2 + a23 yi3 )  mod  m2
zi = ( xi yi )  mod  m1
ui = (zi + 1) / d
xi = ( a11 xi-1 + a12 xi-2 + a13 xi-3 ) mod m1 yi = ( a21 yi-1 + a22 yi-2 + a23 yi-3 ) mod m2 zi = ( xi - yi ) mod m1 ui = ( zi + 1 ) / d
where a11 = 0 a11 = 0 , a12 = 1403580 a12 = 1403580 , a13 = -810728 a13 = -810728 , m1 = 232209 m1 = 232-209 , a21 = 527612 a21 = 527612 , a22 = 0 a22 = 0 , a23 = -1370589 a23 = -1370589 , m2 = 23222853 m2 = 232-22853 , and ui , i = 1 , 2 , ui , i = 1 , 2 ,  form the required sequence. If d = m1d=m1 then ui(0,1]ui(0,1] else if d = m1 + 1d=m1+1 then ui(0,1)ui(0,1). Combining the two multiple recursive generators (MRG) results in sequences with better statistical properties in high dimensions and longer periods compared with those generated from a single MRG. The combined generator described above has a period length of approximately 21912191.

Quasi-random Numbers

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.
The quasi-random number generators implemented in this chapter generate a set of points x1,x2,,xNx1,x2,,xN with high uniformity in the SS-dimensional unit cube IS = [0,1]SIS=[0,1]S. One measure of the uniformity is the discrepancy which is defined as follows:
Three types of low-discrepancy sequences are supplied in this library, these are due to Sobol, Faure and Niederreiter. Two sets of Sobol sequences are supplied, the first is based on work of Joe and Kuo (2008) and the second on the work of Bratley and Fox (1988). More information on quasi-random number generation and the Sobol, Faure and Niederreiter sequences in particular can be found in Bratley and Fox (1988) and Fox (1986).
The efficiency of a simulation exercise may often be increased by the use of variance reduction methods (see Morgan (1984)). It is also worth considering whether a simulation is the best approach to solving the problem. For example, low-dimensional integrals are usually more efficiently calculated by functions in Chapter D01 rather than by Monte–Carlo integration.

Scrambled Quasi-random Numbers

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 both Sobol sequences and the Niederreiter sequence can be obtained.

Non-uniform Random Numbers

Random numbers from other distributions may be obtained from the uniform random numbers by the use of transformations and rejection techniques, and for discrete distributions, by table based methods.
(a) Transformation Methods
For a continuous random variable, if the cumulative distribution function (CDF) is F(x)F(x) then for a uniform (0,1)(0,1) random variate uu, y = F1(u)y=F-1(u) will have CDF F(x)F(x). This method is only efficient in a few simple cases such as the exponential distribution with mean μμ, in which case F1(u) = μloguF-1(u)=-μlogu. Other transformations are based on the joint distribution of several random variables. In the bivariate case, if vv and ww are random variates there may be a function gg such that y = g(v,w)y=g(v,w) has the required distribution; for example, the Student's tt-distribution with nn degrees of freedom in which vv has a Normal distribution, ww has a gamma distribution and g(v,w) = v×sqrt(n / w)g(v,w)=vn/w.
(b) Rejection Methods
Rejection techniques are based on the ability to easily generate random numbers from a distribution (called the envelope) similar to the distribution required. The value from the envelope distribution is then accepted as a random number from the required distribution with a certain probability; otherwise, it is rejected and a new number is generated from the envelope distribution.
(c) Table Search Methods
For discrete distributions, if the cumulative probabilities, Pi = Prob(xi)Pi=Prob(xi), are stored in a table then, given uu from a uniform (0,1)(0,1) distribution, the table is searched for ii such that Pi1 < uPiPi-1<uPi. The returned value ii will have the required distribution. The table searching can be made faster by means of an index, see Ripley (1987). The effort required to set up the table and its index may be considerable, but the methods are very efficient when many values are needed from the same distribution.

Copulas

A copula is a function that links the univariate marginal distributions with their multivariate distribution. Sklar's theorem (see Sklar (1973)) states that if ff is an mm-dimensional distribution function with continuous margins f1 , f2 ,, fm f1 , f2 ,, fm , then ff has a unique copula representation, cc, such that
f (x1,x2,,xm) = c (f1(x1),f2(x2),,fm(xm))
f ( x1 , x2 ,, xm ) = c ( f1 (x1) , f2 (x2) ,, fm (xm) )
The copula, cc, is a multivariate uniform distribution whose dependence structure is defined by the dependence structure of the multivariate distribution ff, with
c (u1,u2,,um) = f (f11(u1),f21(u2),,fm1(um))
c ( u1 , u2 ,, um ) = f ( f1-1 (u1) , f2-1 (u2) , , fm-1 (um) )
where ui [0,1] ui [0,1] . This relationship can be used to simulate variates from distributions defined by the dependence structure of one distribution and each of the marginal distributions given by another. For additional information see Nelsen (1998) or Boye (Unpublished manuscript) and the references therein.

Brownian Bridge

Brownian Bridge Process

Fix two times t0 < Tt0<T and let W = (Wt) 0tTt0 W = (Wt) 0tT-t0  be a standard dd-dimensional Wiener process on the interval [0,Tt0][0,T-t0]. Recall that the terms Wiener process and Brownian motion are often used interchangeably.
A standard dd-dimensional Brownian bridge B = (Bt)t0tT B = (Bt) t0tT  on [t0,T][t0,T] is defined (see Revuz and Yor (1999)) as
Bt = Wtt0 (tt0)/(Tt0) WTt0 .
Bt = W t-t0 - t-t0 T-t0 WT-t0 .
The process is continuous, starts at zero at time t0t0 and ends at zero at time TT. It is Gaussian, has zero mean and has a covariance structure given by
𝔼 (BsBtT) = ( (st0) (Tt) )/(Tt0) Id
𝔼 ( Bs BtT ) = (s-t0) (T-t) T-t0 Id
for any stst in [t0,T][t0,T] where IdId is the dd-dimensional identity matrix. The Brownian bridge is often called a non-free or ‘pinned’ Wiener process since it is forced to be 00 at time TT, but is otherwise very similar to a standard Wiener process.
We can generalize this construction as follows. Fix points x,wdx,wd, let ΣΣ be a d × dd×d covariance matrix and choose any d × dd×d matrix CC such that CCT = ΣCCT=Σ. The generalized dd-dimensional Brownian bridge X = (Xt)t0tT X = (Xt) t0tT  is defined by setting
Xt = ( (tt0) w + (Tt) x )/(Tt0) + CBt = ( (tt0) w + (Tt) x )/(Tt0) + CWt t0 ( (tt0) )/(Tt0) C WTt0
Xt = (t-t0) w+ (T-t) x T-t0 + CBt = (t-t0) w+ (T-t) x T-t0 + CWt - t0 - (t-t0) T-t0 C W T-t0
for all t[t0,T]t[t0,T]. The process XX is continuous, starts at xx at time t0t0 and ends at ww at time TT. It has mean ((tt0)w + (Tt)x) / (Tt0) ( (t-t0) w+ (T-t) x ) / (T-t0)  and covariance structure
𝔼 (Xs𝔼Xs) (Xt𝔼Xt)T = 𝔼 (CBsBtTCT) = ( (st0) (Tt) )/(Tt0) Σ
𝔼 ( Xs - 𝔼 Xs ) ( Xt - 𝔼 Xt )T = 𝔼 ( C Bs BtT CT ) = (s-t0) (T-t) T-t0 Σ
for all stst in [t0,T][t0,T]. This is a non-free Wiener process since it is forced to be equal to ww at time TT. However if we set w = x + CWTt0w=x+CWT-t0, then XX simplifies to
Xt = x + C Wtt0
Xt = x+C W t-t0
for all t[t0,T]t[t0,T] which is nothing other than a dd-dimensional Wiener process with covariance given by ΣΣ.
Two sample paths for a two-dimensional free Wiener process
Figure 1: Two sample paths for a two-dimensional free Wiener process
Figure 1 shows two sample paths for a two-dimensional free Wiener process X = (Xt1,Xt2) 0t2 X = ( Xt1 , Xt2 ) 0t2 . The correlation coefficient between the one-dimensional processes X1X1 and X2X2 at any time is ρ = 0.80ρ=0.80. Note that the red and green paths in each figure are uncorrelated, however it is fairly evident that the two red paths are correlated, and that the two green paths are correlated (when one path increases so does the other, and vice versa).
Two sample paths for a two-dimensional non-free Wiener process. The process starts at 0,0 and ends at 1,-1
Figure 2: Two sample paths for a two-dimensional non-free Wiener process. The process starts at (0,0)(0,0) and ends at (1,1)(1,-1)
Figure 2 shows two sample paths for a two-dimensional non-free Wiener process. The process starts at (0,0) (0,0)  and ends at (1,1) (1,-1) . The correlation coefficient between the one-dimensional processes is again ρ = 0.80ρ=0.80. The red and green paths in each figure are uncorrelated, while the two red paths tend to increase and decrease together, as do the two green paths. Both Figure 1 and Figure 2 were constructed using nag_rand_bb (g05xb).

Brownian Bridge Algorithm

The ideas above can also be used to construct sample paths of a free or non-free Wiener process (recall that a non-free Wiener process is the Brownian bridge process outlined above). Fix two times t0 < Tt0<T and let (ti)1iN (ti) 1iN  be any set of time points satisfying t0 < t1 < t2 <⋯< tN < Tt0<t1<t2<⋯<tN<T. Let (Xti)1iN ( X ti ) 1iN  denote a dd-dimensional (free or non-free) Wiener sample path at these times. These values can be generated by the so-called Brownian bridge algorithm (see Glasserman (2004)) which works as follows. From any two known points Xti X ti  at time titi and Xtk X tk  at time tktk with ti < tkti<tk, a new point Xtj X tj  can be interpolated at any time tj (ti,tk) tj (ti,tk)  by setting
Xtj = ( Xti (tktj) + Xtk (tjti) )/( tkti ) + C Z sqrt( ( (tktj) (tjti) )/( (tkti) ) )
Xtj = Xti ( tk - tj ) + Xtk ( tj - ti ) tk-ti + C Z ( tk - tj ) ( tj - ti ) ( tk - ti )
(2)
where ZZ is a dd-dimensional standard Normal random variable and CC is any d × dd×d matrix such that CCTCCT is the desired covariance structure for the (free or non-free) Wiener process XX. Clearly this algorithm is iterative in nature. All that is needed to complete the specification is to fix the start point Xt0Xt0 and end point XTXT, and to specify how successive interpolation times tjtj are chosen. For XX to behave like a usual (free) Wiener process we should set Xt0Xt0 equal to some value xdxd and then set XT = x + Csqrt(Tt0)ZXT=x+CT-t0Z where ZZ is any dd-dimensional standard Normal random variable. However when it comes to deciding how the successive interpolation times tjtj should be chosen, there is virtually no restriction. Any method of choosing which tj (ti,tk) tj (ti,tk)  to interpolate next is equally valid, provided titi is the nearest known point to the left of tjtj and tktk is the nearest known point to the right of tjtj. In other words, the interpolation interval (ti,tk)(ti,tk) must not contain any other known points, otherwise the covariance structure of the process will be incorrect.
The order in which the successive interpolation times tjtj are chosen is called the bridge construction order. Since all construction orders will produce a correct process, the question arises whether one construction order should be preferred over another. When the ZZ values are drawn from a pseudorandom generator, the answer is typically no. However the bridge algorithm is frequently used with quasi-random numbers, and in this case the bridge construction order can be important.

Bridge Construction Order and Quasi-random Sequences

Consider the one-dimensional case of a free Wiener process where d = C = 1d=C=1. The Brownian bridge is frequently combined with low-discrepancy (quasi-random) sequences to perform quasi-Monte–Carlo integration. Quasi-random points Z1, Z2, Z3, Z1, Z2, Z3,  are generated from the standard Normal distribution, where each quasi-random point Zi = (Z1i,Z2i,,ZDi) Zi = (Z1i,Z2i,,ZDi)  consists of DD one-dimensional values. The process XX starts at Xt0 = xXt0=x which is known. There remain N + 1N+1 time points at which the bridge is to be computed, namely (Xti)1iN ( X ti ) 1iN  and XTXT (recall we are considering a free Wiener process). In this case DD is set equal to N + 1N+1, so that N + 1N+1 dimensional quasi-random points are generated. A single quasi-random point is used to construct one Wiener sample path.
The question is how to use the dimension values of each N + 1N+1 dimensional quasi-random point. Often the ‘lower’ dimension values (Z1i,Z2iZ1i,Z2i, etc.) display better uniformity properties than the ‘higher’ dimension values (ZN + 1i,ZNiZN+1i,ZNi, etc.) so that the ‘lower’ dimension values should be used to construct the most important sections of the sample path. For example, consider a model which is particularly sensitive to the behaviour of the underlying process at time 33. When constructing the sample paths, one would therefore ensure that time 33 was one of the interpolation points of the bridge, and that a ‘lower’ dimension value was used in (2) to construct the corresponding bridge point X3X3. Indeed, one would most likely also ensure that time X3X3 was one of the first bridge points that was constructed: ‘lower’ dimension values would be used to construct both the left and right bridge points used in (2) to interpolate X3X3, so that the distribution of X3X3 benefits as much as possible from the uniformity properties of the quasi-random sequence. For further discussions in this regard we refer to Glasserman (2004). These remarks extend readily to the case of a non-free Wiener process.

Brownian Bridge and Stochastic Differential Equations

The Brownian bridge algorithm, especially when combined with quasi-random variates, is frequently used to obtain numerical solutions to stochastic differential equations (SDEs) driven by (free or non-free) Wiener processes. The quasi-random variates produce a family of Wiener sample paths which cover the space of all Wiener sample paths fairly evenly. This is analogous to the way in which a two-dimensional quasi-random sequence covers the unit square [0,1]2[0,1]2 evenly. When solving SDEs one is typically interested in the increments of the driving Wiener process between two time points, rather than the value of the process at a particular time point. Section [Brownian Bridge] contains details on which functions can be used to obtain such Wiener increments.

Random Fields

A random field is a stochastic process, taking values in a Euclidean space, and defined over a parameter space of dimensionality at least one. They are often used to simulate some physical space-dependent parameter, such as the permeability of rock, which cannot be measured at every point in the space. The simulated values can then be used to model other dependent quantities, for example, underground flow of water, often through the use of partial differential equations (PDEs).
A dd-dimensional random field Z(x)Z(x) is a function which is random at every point (xD)(xD) for some domain DdDd, so Z(x)Z(x) is a random variable for each xx. The random field has a mean function μ(x) = 𝔼[Z(x)]μ(x)=𝔼[Z(x)] and a symmetric positive semidefinite covariance function C(x,y) = 𝔼[(Z(x)μ(x))(Z(y)μ(y))]C(x,y)=𝔼[(Z(x)-μ(x))(Z(y)-μ(y))].
A random field, Z(x)Z(x), is a Gaussian random field if, for any choice of nn and x1,,xndx1,,xnd, the random vector [Z(x1),,Z(xn)]T[Z(x1),,Z(xn)]T follows a multivariate Gaussian distribution.
A Gaussian random field Z(x)Z(x) is stationary if μ(x)μ(x) is constant for all xx and C(x,y) = C(x + a,y + a)C(x,y)=C(x+a,y+a) for all x,y,adx,y,ad and hence we can express the covariance function C(x,y)C(x,y) as a function γγ of one variable: C(x,y) = γ(xy)C(x,y)=γ(x-y). γγ is known as a variogram (or more correctly, a semivariogram) and includes the multiplicative factor σ2σ2 representing the variance such that γ(0) = σ2γ(0)=σ2. There are a number of commonly used variograms, including:
  1. Symmetric stable variogram
    γ(x) = σ2 exp((x)ν)
    γ(x) = σ2 exp( - (x) ν )
  2. Cauchy variogram
    γ(x) = σ2 (1 + (x)2)ν .
    γ(x) = σ2 ( 1+ (x) 2 ) -ν .
  3. Differential variogram with compact support
    γ(x) =
    { σ2(1 + 8x + 25(x)2 + 32(x)3)(1 − x)8, x < 1, 0, x ≥ 1.
    γ(x) = { σ2(1+8x+25(x)2+32(x)3)(1-x)8, x<1, 0, x1.
  4. Exponential variogram
    γ(x) = σ2exp(x).
    γ(x)=σ2exp(-x).
  5. Gaussian variogram
    γ(x) = σ2exp((x)2).
    γ(x)=σ2exp(-(x)2).
  6. Nugget variogram
    γ(x) =
    { σ2, x = 0, 0, x ≠ 0.
    γ(x)={ σ2, x=0, 0, x0.
  7. Spherical variogram
    γ(x) =
    { σ2(1 − 1.5x + 0.5(x)3), x < 1, 0, x ≥ 1.
    γ(x)={ σ2(1-1.5x+0.5(x)3), x<1, 0, x1.
  8. Bessel variogram
    γ(x) = σ2(2νΓ(ν + 1)Jν(x))/((x)ν),
    γ(x)=σ22νΓ(ν+1)Jν(x)(x)ν,
  9. Hole effect variogram
    γ(x) = σ2(sin(x))/(x).
    γ(x)=σ2sin(x)x.
  10. Whittle–Matérn variogram
    γ(x) = σ2(21ν(x)νKν(x))/(Γ(ν)),
    γ(x)=σ221-ν(x)νKν(x)Γ(ν),
  11. Continuously parameterised variogram with compact support
    γ(x) =
    { σ2(21 − ν(x)νKν(x))/(Γ(ν))(1 + 8x′′ + 25(x′′)2 + 32(x′′)3)(1 − x′′)8, x′′ < 1, 0, x′′ ≥ 1,
    γ(x)={ σ221-ν(x)νKν(x)Γ(ν)(1+8x+25(x)2+32(x)3)(1-x)8, x<1, 0, x1,
  12. Generalized hyperbolic distribution variogram
    γ(x) = σ2((δ2 + (x)2)λ/2)/(δλKλ(κδ))Kλ(κ(δ2 + (x)2)(1/2)),
    γ(x)=σ2(δ2+(x)2)λ2δλKλ(κδ)Kλ(κ(δ2+(x)2)12),
  13. Cosine variogram
    γ(x) = σ2cos(x),
    γ(x)=σ2cos(x),
where xx is a scaled norm of xx

Other Random Structures

In addition to random numbers from various distributions, random compound structures can be generated. These include random time series, random matrices and random samples.

Multiple Streams of Pseudorandom Numbers

It is often advantageous to be able to generate variates from multiple, independent, streams (or sequences) of random variates. For example when running a simulation in parallel on several processors. There are four ways of generating multiple streams using the functions available in this chapter:
(i) using different initial values (seeds);
(ii) using different generators;
(iii) skip ahead (also called block-splitting);
(iv) leap-frogging.

Multiple Streams via Different Initial Values (Seeds)

A different sequence of variates can be generated from the same base generator by initializing the generator using a different set of seeds. The statistical properties of the base generators are only guaranteed within, not between sequences. For example, two sequences generated from two different starting points may overlap if these initial values are not far enough apart. The potential for overlapping sequences is reduced if the period of the generator being used is large. In general, of the four methods for creating multiple streams described here, this is the least satisfactory.
The one exception to this is the Wichmann–Hill II generator. The Wichmann and Hill (2006) paper describes a method of generating blocks of variates, with lengths up to 290290, by fixing the first three seed values of the generator (w0w0, x0x0 and y0y0), and setting z0z0 to a different value for each stream required. This is similar to the skip-ahead method described in Section [Multiple Streams via Skip-ahead], in that the full sequence of the Wichmann–Hill II generator is split into a number of different blocks, in this case with a fixed length of 290290. But without the computationally intensive initialization usually required for the skip-ahead method.

Multiple Streams via Different Generators

Independent sequences of variates can be generated using a different base generator for each sequence. For example, sequence 1 can be generated using the NAG basic generator, sequence 2 using Mersenne Twister, sequence 3 the ACORN generator and sequence 4 using L'Ecuyer generator. The Wichmann–Hill I generator implemented in this chapter is, in fact, a series of 273 independent generators. The particular sub-generator to use is selected using the subid variable. Therefore, in total, 278 independent streams can be generated with each using a different generator (273 Wichmann–Hill I generators, and 5 additional base generators).

Multiple Streams via Skip-ahead

Independent sequences of variates can be generated from a single base generator through the use of block-splitting, or skipping-ahead. This method consists of splitting the sequence into kk non-overlapping blocks, each of length nn, where nn is no smaller than the maximum number of variates required from any of the sequences. For example,
( x1 , x2 , , xn )/(block 1) , ( xn + 1 , xn + 2 , , x2n )/(block 2) , ( x2n + 1 , x2n + 2 , , x3n )/(block 3) , etc.
x1 , x2 , , xn block 1 , xn+1 , xn+2 , , x2n block 2 , x2n+1 , x2n+2 , , x3n block 3 , etc.
where x1,x2,x1,x2, is the sequence produced by the generator of interest. Each of the kk blocks provide an independent sequence.
The skip-ahead algorithm therefore requires the sequence to be advanced a large number of places, as to generate values from say, block bb, you must skip over the (b1)n(b-1)n values in the first b1b-1 blocks. Due to their form this can be done efficiently for linear congruential generators and multiple congruential generators. A skip-ahead algorithm is also provided for the Mersenne Twister generator.
Although skip-ahead requires some additional computation at the initialization stage (to ‘fast forward’ the sequence) no additional computation is required at the generation stage.
This method of producing multiple streams can also be used for the Sobol and Niederreiter quasi-random number generator via the parameter iskip in nag_rand_quasi_init (g05yl).

Multiple Streams via Leap-frog

Independent sequences of variates can also be generated from a single base generator through the use of leap-frogging. This method involves splitting the sequence from a single generator into kk disjoint subsequences. For example:
Subsequence 1: x1 , xk + 1 , x2k + 1 ,
Subsequence 2: x2 , xk + 2 , x2k + 2 ,
Subsequence ​k: xk , x2k , x3k , ,
Subsequence 1: x1 , xk+1 , x 2k+1 , Subsequence 2: x2 , xk+2 , x 2k+2 , Subsequence ​k: xk , x2k , x3k , ,
where x1,x2,x1,x2, is the sequence produced by the generator of interest. Each of the kk subsequences then provides an independent stream of variates.
The leap-frog algorithm therefore requires the generation of every kkth variate from the base generator. Due to their form this can be done efficiently for linear congruential generators and multiple congruential generators. A leap-frog algorithm is provided for the NAG Basic generator, both the Wichmann–Hill I and Wichmann–Hill II generators and L'Ecuyer generator.
It is known that, dependent on the number of streams required, leap-frogging can lead to sequences with poor statistical properties, especially when applied to linear congruential generators. In addition, leap-frogging can increase the time required to generate each variate. Therefore leap-frogging should be avoided unless absolutely necessary.

Skip-ahead and Leap-frog for a Linear Congruential Generator (LCG): An Example

As an illustrative example, a brief description of the algebra behind the implementation of the leap-frog and skip-ahead algorithms for a linear congruential generator is given. A linear congruential generator has the form xi + 1 = a1 xi  mod  m1xi+1=a1 xi  mod  m1. The recursive nature of a linear congruential generator means that
xi + v = a1 xi + v1  mod  m1
= a1 (a1xi + v2 mod m1)  mod  m1
= a12 xi + v2  mod  m1
= a1v xi  mod  m1 .
xi+v = a1 x i+v-1  mod  m1 = a1 ( a1 x i+v-2  mod  m1 )  mod  m1 = a 1 2 x i+v-2  mod  m1 = a1v xi  mod  m1 .
The sequence can therefore be quickly advanced vv places by multiplying the current state (xixi) by a1v  mod  m1a1v  mod  m1, hence skipping the sequence ahead. Leap-frogging can be implemented by using a1ka1k, where kk is the number of streams required, in place of a1a1 in the standard linear congruential generator recursive formula, in order to advance kk places, rather than one, at each iteration.
In a linear congruential generator the multiplier a1a1 is constructed so that the generator has good statistical properties in, for example, the spectral test. When using leap-frogging to construct multiple streams this multiplier is replaced with a1ka1k, and there is no guarantee that this new multiplier will have suitable properties especially as the value of kk depends on the number of streams required and so is likely to change depending on the application. This problem can be emphasized by the lattice structure of linear congruential generators. Similiarly, the value of a1a1 is often chosen such that the computation a1 xi  mod  m1a1 xi  mod  m1 can be performed efficiently. When a1a1 is replaced by a1ka1k, this is often no longer the case.
Note that, due to rounding, when using a distributional generator, a sequence generated using leap-frogging and a sequence constructed by taking every kk value from a set of variates generated without leap-frogging may differ slightly. These differences should only affect the least significant digit.

Skip-ahead and Leap-frog for the Mersenne Twister: An Example

Skipping ahead with the Mersenne Twister generator is based on the definition of a k × kk×k (where k = 19937k=19937) transition matrix, AA, over the finite field 𝔽2𝔽2 (with elements 0 and 1). Multiplying AA by the current state xnxn, represented as a vector of bits, produces the next state vector xn + 1xn+1:
x n + 1 = A xn .
x n + 1 = A x n .
Thus, skipping ahead vv places in a sequence is equivalent to multiplying by AvAv:
x n + v = Av xn .
x n + v = A v x n .
Since calculating AvAv by a standard square and multiply algorithm is O(k3logv)O(k3 logv) and requires over 47MB of memory (see Haramoto et al. (2008)), an indirect calculation is performed which relies on a property of the characteristic polynomial p(z)p(z) of AA, namely that p(A) = 0p(A)=0. We then define
g(z) = zv  mod  p(z) = a k 1 z k 1 + + a1 z + a0 ,
g(z) = z v  mod  p(z) = a k - 1 z k - 1 + + a 1 z + a 0 ,
and observe that
g(z) = zv + q(z) p (z)
g(z) = z v + q(z) p ( z )
for a polynomial q(z)q(z). Since p(A) = 0p(A)=0, we have that g (A) = Av g ( A ) = A v  and
Av xn = (a k 1 A k 1 + + a1A + a0I) xn .
A v x n = ( a k - 1 A k - 1 + + a 1 A + a 0 I ) x n .
This polynomial evaluation can be performed using Horner's method:
Av xn = A (A(A(Aa k 1 xn + a k 2 xn) + a k 3 xn) + + a1xn) + a0 xn ,
A v x n = A ( A ( A ( A a k - 1 x n + a k - 2 x n ) + a k - 3 x n ) + + a 1 x n ) + a 0 x n ,
which reduces the problem to advancing the generator k1k-1 places from state xnxn and adding (where addition is as defined over 𝔽2𝔽2) the intermediate states for which aiai is nonzero.
There are therefore two stages to skipping the Mersenne Twister ahead vv places:
(i) Calculate the coefficients of the polynomial g (z) = zv  mod  p (z) g ( z ) = z v  mod  p ( z ) ;
(ii) advance the sequence k1k-1 places from the starting state and add the intermediate states that correspond to nonzero coefficients in the polynomial calculated in the first step.
The resulting state is that for position vv in the sequence.
The cost of calculating the polynomial is O(k2logv) O( k 2 logv )  and the cost of applying it to state is constant. Skip ahead functionality is typically used in order to generate nn independent pseudorandom number streams (e.g., for separate threads of computation). There are two options for generating the nn states:
(i) On the master thread calculate the polynomial for a skip ahead distance of vv and apply this polynomial to state nn times, after each iteration jj saving the current state for later usage by thread jj.
(ii) Have each thread jj independently and in parallel with other threads calculate the polynomial for a distance of (j + 1)v(j+1)v and apply to the original state.
Since lim v   logv = log n v lim v logv = log n v , then for large vv the cost of generating the polynomial for a skip ahead distance of nvnv (i.e., the calculation performed by thread n1n-1 in option (ii) above) is approximately the same as generating that for a distance of vv (i.e., the calculation performed by thread 00). However, only one application to state need be made per thread, and if nn is sufficiently large the cost of applying the polynomial to state becomes the dominant cost in option (i), in which case it is desirable to use option (ii). Tests have shown that as a guideline it becomes worthwhile to switch from option (i) to option (ii) for approximately n > 30n>30.
Leap frog calculations with the Mersenne Twister are performed by computing the sequence fully up to the required size and discarding the redundant numbers for a given stream.

Recommendations on Choice and Use of Available Functions

Pseudorandom Numbers

Prior to generating any pseudorandom variates the base generator being used must be initialized. Once initialized, a distributional generator can be called to obtain the variates required. No interfaces have been supplied for direct access to the base generators. If a sequence of random variates from a uniform distribution on the open interval (0,1)(0,1), is required, then the uniform distribution function (nag_rand_dist_uniform01 (g05sa)) should be called.

Initialization

Prior to generating any variates the base generator must be initialized. Two utility functions are provided for this, nag_rand_init_repeat (g05kf) and nag_rand_init_nonrepeat (g05kg), both of which allow any of the base generators to be chosen.
nag_rand_init_repeat (g05kf) selects and initializes a base generator to a repeatable (when executed serially) state: two calls of nag_rand_init_repeat (g05kf) with the same argument-values will result in the same subsequent sequences of random numbers (when both generated serially).
nag_rand_init_nonrepeat (g05kg) selects and initializes a base generator to a non-repeatable state in such a way that different calls of nag_rand_init_nonrepeat (g05kg), either in the same run or different runs of the program, will almost certainly result in different subsequent sequences of random numbers.
No utilities for saving, retrieving or copying the current state of a generator have been provided. All of the information on the current state of a generator (or stream, if multiple streams are being used) is stored in the integer array state and as such this array can be treated as any other integer array, allowing for easy copying, restoring, etc.

Repeated initialization

As mentioned in Section [Multiple Streams via Different Initial Values (Seeds)], it is important to note that the statistical properties of pseudorandom numbers are only guaranteed within sequences and not between sequences produced by the same generator. Repeated initialization will thus render the numbers obtained less rather than more independent. In a simple case there should be only one call to nag_rand_init_repeat (g05kf) or nag_rand_init_nonrepeat (g05kg) and this call should be before any call to an actual generation function.

Choice of Base Generator

If a single sequence is required then it is recommended that the Mersenne Twister is used as the base generator (genid = 3genid=3). This generator is fast, has an extremely long period and has been shown to perform well on various test suites, see Matsumoto and Nishimura (1998), L'Ecuyer and Simard (2002) and Wichmann and Hill (2006) for example.
When choosing a base generator, the period of the chosen generator should be borne in mind. A good rule of thumb is never to use more numbers than the square root of the period in any one experiment as the statistical properties are impaired. For closely related reasons, breaking numbers down into their bit patterns and using individual bits may also cause trouble.

Choice of Method for Generating Multiple Streams

If the Wichmann–Hill II base generator is being used, and a period of 290290 is sufficient, then the method described in Section [Multiple Streams via Different Initial Values (Seeds)] can be used. If a different generator is used, or a longer period length is required then generating multiple streams by altering the initial values should be avoided.
Using a different generator works well if less than 277 streams are required.
Of the remaining two methods, both skip-ahead and leap-frogging use the sequence from a single generator, both guarantee that the different sequences will not overlap and both can be scaled to an arbitrary number of streams. Leap-frogging requires no a-priori knowledge about the number of variates being generated, whereas skip-ahead requires you to know (approximately) the maximum number of variates required from each stream. Skip-ahead requires no a-priori information on the number of streams required. In contrast leap-frogging requires you to know the maximum number of streams required, prior to generating the first value. Of these two, if possible, skip-ahead should be used in preference to leap-frogging. Both methods required additional computation compared with generating a single sequence, but for skip-ahead this computation occurs only at initialization. For leap-frogging additional computation is required both at initialization and during the generation of the variates. In addition, as mentioned in Section [Multiple Streams via Leap-frog], using leap-frogging can, in some instances, change the statistical properties of the sequences being generated.
Leap-frogging is performed by calling nag_rand_init_leapfrog (g05kh) after the initialization function (nag_rand_init_repeat (g05kf) or nag_rand_init_nonrepeat (g05kg)). For skip-ahead, either nag_rand_init_skipahead (g05kj) or nag_rand_init_skipahead_power2 (g05kk) can be called. Of these, nag_rand_init_skipahead_power2 (g05kk) restricts the amount being skipped to a power of 22, but allows for a large ‘skip’ to be performed.

Copulas

After calling one of the copula functions the inverse cumulative distribution function (CDF) can be applied to convert the uniform marginal distribution into the required form. Scalar and vector routines for evaluating the CDF, for a range of distributions, are supplied in Chapter G01. If should be noted that these routines are often described as computing the ‘deviates’ of the distribution.
When using the inverse CDF functions from Chapter G01 it should be noted that some are limited in the number of significant figures they return. This may affect the statistical properties of the resulting sequence of variates. Section 7 of the individual function documentation will give a discussion of the accuracy of the particular algorithm being used and any available alternatives.

Quasi-random Numbers

Prior to generating any quasi-random variates the generator being used must be initialized via nag_rand_quasi_init (g05yl) or nag_rand_quasi_init_scrambled (g05yn). Of these, nag_rand_quasi_init (g05yl) can be used to initialize a standard Sobol, Faure or Niederreiter sequence and nag_rand_quasi_init_scrambled (g05yn) can be used to initialize a scrambled Sobol or Niederreiter sequence.
Due to the random nature of the scrambling, prior to calling the initialization function nag_rand_quasi_init_scrambled (g05yn) one of the pseudorandom initialization functions, nag_rand_init_repeat (g05kf) or nag_rand_init_nonrepeat (g05kg), must be called.
Once a quasi-random generator has been initialized, using either nag_rand_quasi_init (g05yl) or nag_rand_quasi_init_scrambled (g05yn), one of three generation functions can be called to generate uniformly distributed sequences (nag_rand_quasi_uniform (g05ym)), Normally distributed sequences (nag_rand_quasi_normal (g05yj)) or sequences with a log-normal distribution (nag_rand_quasi_lognormal (g05yk)). For example, for a repeatable sequence of scrambled quasi-random variates from the Normal distribution, nag_rand_init_repeat (g05kf) must be called first (to initialize a pseudorandom generator), followed by nag_rand_quasi_init_scrambled (g05yn) (to initialize a scrambled quasi-random generator) and then nag_rand_quasi_normal (g05yj) can be called to generate the sequence from the required distribution.
See the last paragraph of Section [Copulas] on how sequences from other distributions can be obtained using the inverse CDF.

Brownian Bridge

nag_rand_bb (g05xb) may be used to generate sample paths from a (free or non-free) Wiener process using the Brownian bridge algorithm. Prior to calling nag_rand_bb (g05xb), the generator must be initialized by a call to nag_rand_bb_init (g05xa). nag_rand_bb_init (g05xa) requires you to specify a bridge construction order. The function nag_rand_bb_make_bridge_order (g05xe) can be used to convert a set of input times into one of several common bridge construction orders, which can then be used in the initialization call to nag_rand_bb_init (g05xa).
nag_rand_bb_inc (g05xd) may be used to generate the scaled increments of the sample paths of a (free or non-free) Wiener process. Prior to calling nag_rand_bb_inc (g05xd), the generator must be initialized by a call to nag_rand_bb_inc_init (g05xc). Note that nag_rand_bb_inc (g05xd) generates these scaled increments directly; it is not necessary to call nag_rand_bb (g05xb) before calling nag_rand_bb_inc (g05xd). As before, nag_rand_bb_make_bridge_order (g05xe) can be used to convert a set of input times into a bridge construction order which can be passed to nag_rand_bb_inc_init (g05xc).

Random Fields

Functions for simulating from either a one-dimensional or a two-dimensional stationary Gaussian random field are provided. These functions use the circulant embedding method of Dietrich and Newsam (1997) to efficiently generate from the required field. In both cases a setup function is called, which defines the domain and variogram to use, followed by the generation function. A number of preset variograms are supplied or a user-defined function can be used.
In addition to generating a random field, it is possible to use the circulant embedding method to generate realisations of fractional Brownian motion, this functionality is provided in nag_rand_field_fracbm_generate (g05zt).
Prior to calling nag_rand_field_1d_generate (g05zp), nag_rand_field_2d_predef_setup (g05zr) or nag_rand_field_fracbm_generate (g05zt) one of the initialization functions, nag_rand_init_repeat (g05kf) or nag_rand_init_nonrepeat (g05kg) must be called.

Functionality Index

Brownian bridge, 
    circulant embedding generator, 
        generate fractional Brownian motion nag_rand_field_fracbm_generate (g05zt)
     increments generator, 
        generate Wiener increments nag_rand_bb_inc (g05xd)
        initialize generator nag_rand_bb_inc_init (g05xc)
    path generator, 
        create bridge construction order nag_rand_bb_make_bridge_order (g05xe)
        generate a free or non-free (pinned) Wiener process for a given set of time steps nag_rand_bb (g05xb)
        initialize generator nag_rand_bb_init (g05xa)
Generating samples, matrices and tables, 
    random correlation matrix nag_rand_matrix_corr (g05py)
    random orthogonal matrix nag_rand_matrix_orthog (g05px)
    random permutation of an integer vector nag_rand_permute (g05nc)
    random sample from an integer vector, 
        unequal weights, without replacement nag_rand_sample_wgt (g05ne)
        unweighted, without replacement nag_rand_sample (g05nd)
    random table nag_rand_matrix_2waytable (g05pz)
Generation of time series, 
    asymmetric GARCH Type II nag_rand_times_garch_asym2 (g05pe)
    asymmetric GJR GARCH nag_rand_times_garch_gjr (g05pf)
    EGARCH nag_rand_times_garch_exp (g05pg)
    exponential smoothing nag_rand_times_smooth_exp (g05pm)
    type I AGARCH nag_rand_times_garch_asym1 (g05pd)
    univariate ARMA nag_rand_times_arma (g05ph)
    vector ARMA nag_rand_times_mv_varma (g05pj)
Pseudorandom numbers, 
    array of variates from multivariate distributions, 
        Dirichlet distribution nag_rand_dist_dirichlet (g05se)
        multinomial distribution nag_rand_int_multinomial (g05tg)
        Normal distribution nag_rand_multivar_normal (g05rz)
        Student's t distribution nag_rand_multivar_students_t (g05ry)
    copulas, 
        Clayton/Cook–Johnson copula (bivariate) nag_rand_copula_clayton_bivar (g05re)
        Clayton/Cook–Johnson copula (multivariate) nag_rand_copula_clayton (g05rh)
        Frank copula (bivariate) nag_rand_copula_frank_bivar (g05rf)
        Frank copula (multivariate) nag_rand_copula_frank (g05rj)
        Gaussian copula nag_rand_copula_normal (g05rd)
        Gumbel–Hougaard copula nag_rand_copula_gumbel (g05rk)
        Plackett copula nag_rand_copula_plackett_bivar (g05rg)
        Student's t copula nag_rand_copula_students_t (g05rc)
    initialize generator, 
        multiple streams, 
            leap-frog nag_rand_init_leapfrog (g05kh)
            skip-ahead nag_rand_init_skipahead (g05kj)
            skip-ahead (power of 2) nag_rand_init_skipahead_power2 (g05kk)
        nonrepeatable sequence nag_rand_init_nonrepeat (g05kg)
        repeatable sequence nag_rand_init_repeat (g05kf)
    vector of variates from discrete univariate distributions, 
        binomial distribution nag_rand_int_binomial (g05ta)
        geometric distribution nag_rand_int_geom (g05tc)
        hypergeometric distribution nag_rand_int_hypergeom (g05te)
        logarithmic distribution nag_rand_int_log (g05tf)
        logical value true or false nag_rand_logical (g05tb)
        negative binomial distribution nag_rand_int_negbin (g05th)
        Poisson distribution nag_rand_int_poisson (g05tj)
        uniform distribution nag_rand_int_uniform (g05tl)
        user-supplied distribution nag_rand_int_general (g05td)
        variate array from discrete distributions with array of parameters, 
            Poisson distribution with varying mean nag_rand_int_poisson_varmean (g05tk)
    vectors of variates from continuous univariate distributions, 
        beta distribution nag_rand_dist_beta (g05sb)
        Cauchy distribution nag_rand_dist_cauchy (g05sc)
        exponential mix distribution nag_rand_dist_expmix (g05sg)
        F-distribution nag_rand_dist_f (g05sh)
        gamma distribution nag_rand_dist_gamma (g05sj)
        logistic distribution nag_rand_dist_logistic (g05sl)
        log-normal distribution nag_rand_dist_lognormal (g05sm)
        negative exponential distribution nag_rand_dist_exp (g05sf)
        Normal distribution nag_rand_dist_normal (g05sk)
        real number from the continuous uniform distribution nag_rand_dist_uniform01 (g05sa)
        Student's t-distribution nag_rand_dist_students_t (g05sn)
        triangular distribution nag_rand_dist_triangular (g05sp)
        uniform distribution nag_rand_dist_uniform (g05sq)
        von Mises distribution nag_rand_dist_vonmises (g05sr)
        Weibull distribution nag_rand_dist_weibull (g05ss)
        χ2 square distribution nag_rand_dist_chisq (g05sd)
Quasi-random numbers, 
    array of variates from univariate distributions, 
        log-normal distribution nag_rand_quasi_lognormal (g05yk)
        Normal distribution nag_rand_quasi_normal (g05yj)
        uniform distribution nag_rand_quasi_uniform (g05ym)
    initialize generator, 
        scrambled Sobol or Niederreiter nag_rand_quasi_init_scrambled (g05yn)
        Sobol, Niederreiter or Faure nag_rand_quasi_init (g05yl)
Random fields, 
    one-dimensional, 
        generation nag_rand_field_1d_generate (g05zp)
        initialize generator, 
            preset variogram nag_rand_field_1d_predef_setup (g05zn)
            user-defined variogram nag_rand_field_1d_user_setup (g05zm)
    two-dimensional, 
        generation nag_rand_field_2d_generate (g05zs)
        initialize generator, 
            preset variogram nag_rand_field_2d_predef_setup (g05zr)
            user-defined variogram nag_rand_field_2d_user_setup (g05zq)

References

Banks J (1998) Handbook on Simulation Wiley
Boye E (Unpublished manuscript) Copulas for finance: a reading guide and some applications Financial Econometrics Research Centre, City University Business School, London
Bratley P and Fox B L (1988) Algorithm 659: implementing Sobol's quasirandom sequence generator ACM Trans. Math. Software 14(1) 88–100
Dietrich C R and Newsam G N (1997) Fast and exact simulation of stationary Gaussian processes through circulant embedding of the covariance matrix SIAM J. Sci. Comput. 18 1088–1107
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)
Fox B L (1986) Algorithm 647: implementation and relative efficiency of quasirandom sequence generators ACM Trans. Math. Software 12(4) 362–376
Glasserman P (2004) Monte Carlo Methods in Financial Engineering Springer
Haramoto H, Matsumoto M, Nishimura T, Panneton F and L'Ecuyer P (2008) Efficient jump ahead for F2-linear random number generators INFORMS J. on Computing 20(3) 385–390
Hong H S and Hickernell F J (2003) Algorithm 823: implementing scrambled digital sequences ACM Trans. Math. Software 29:2 95–109
Joe S and Kuo F Y (2008) Constructing Sobol sequences with better two-dimensional projections SIAM J. Sci. Comput. 30 2635–2654
Knuth D E (1981) The Art of Computer Programming (Volume 2) (2nd Edition) Addison–Wesley
L'Ecuyer P and Simard R (2002) TestU01: a software library in ANSI C for empirical testing of random number generators Departement d'Informatique et de Recherche Operationnelle, Universite de Montreal http://www.iro.umontreal.ca/~lecuyer
Maclaren N M (1989) The generation of multiple independent sequences of pseudorandom numbers Appl. Statist. 38 351–359
Matsumoto M and Nishimura T (1998) Mersenne twister: a 623-dimensionally equidistributed uniform pseudorandom number generator ACM Transactions on Modelling and Computer Simulations
Morgan B J T (1984) Elements of Simulation Chapman and Hall
Nelsen R B (1998) An Introduction to Copulas. Lecture Notes in Statistics 139 Springer
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)
Revuz D and Yor M (1999) Continuous Martingales and Brownian Motion Springer
Ripley B D (1987) Stochastic Simulation Wiley
Sklar A (1973) Random variables: joint distribution functions and copulas Kybernetika 9 499–460
Wichmann B A and Hill I D (2006) Generating good pseudo-random numbers Computational Statistics and Data Analysis 51 1614–1622
Wikramaratna R S (1989) ACORN - a new method for generating sequences of uniformly distributed pseudo-random numbers Journal of Computational Physics 83 16–31
Wikramaratna R S (1992) Theoretical background for the ACORN random number generator Report AEA-APS-0244 AEA Technology, Winfrith, Dorest, UK
Wikramaratna R S (2007) The additive congruential random number generator a special case of a multiple recursive generator Journal of Computational and Applied Mathematics

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013