|
NAG[g05ybc] NAG[nag_quasi_random_normal] - Multi-dimensional quasi-random number generator with a Gaussian or log-normal probability distribution
|
|
Calling Sequence
g05ybc(state, sequence_type, lnorm, mean, std, iskip, quasi, gf, 'idim'=idim, 'fail'=fail)
nag_quasi_random_normal(. . .)
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 already been initialized by a prior call to nag_quasi_random_normal (g05ybc) 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". .
|
|
|
lnorm - String;
|
|
|
On entry: indicates whether to create Gaussian or log-normal variates.
|
|
The variates are log-normal.
|
|
The variates are Gaussian.
|
|
Constraint: "Nag_LogNormal" or "Nag_Normal". .
|
|
|
mean - Vector(1..idim, datatype=float[8]);
|
|
|
On entry: is the mean of distribution for the th dimension.
|
|
|
std - Vector(1..idim, datatype=float[8]);
|
|
|
On entry: is the standard deviation of the distribution for the th dimension.
|
|
Constraint: , for . .
|
|
|
iskip - integer;
|
|
|
On entry: the number of terms in the sequence to skip on initialization.
|
|
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: and . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
To generate multi-dimensional quasi-random sequences with a Gaussian or log-normal 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_normal (g05ybc) generates multi-dimensional quasi-random sequences with a Gaussian or log-normal probability distribution. The sequences are generated in pairs using the Box–Muller method. This means that an even number of dimensions are required by this function. If an odd number of dimensions are required then the extra dimension must be computed, but can then be ignored.
This function uses the sequences as described in g05yac (nag_quasi_random_uniform).
|
|
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. For more information see g05yac (nag_quasi_random_uniform).
|
|
|
Examples
|
|
>
|
state := "Nag_QuasiRandom_Init":
seq_type := "Nag_QuasiRandom_Faure":
lnorm := "Nag_Normal":
iskip := 0:
idim := 20:
gf := NAG:-Nag_QuasiRandom():
mean := Vector(idim, 2.0, datatype=float[8]):
std := Vector(idim, 1.0, datatype=float[8]):
quasi := Vector(idim, datatype=float[8]):
NAG:-g05ybc(state, seq_type, lnorm, mean, std, iskip, quasi, gf, 'idim' = idim) ;
thesum := 0.0:
state := "Nag_QuasiRandom_Cont":
ntimes := 10000:
for i from 1 to ntimes do
NAG:-g05ybc(state, seq_type, lnorm, mean, std, iskip, quasi, gf, 'idim' = idim):
#):
thesum := thesum + add( ((quasi[j]-mean[j])/std[j])^4, j=1..idim ):
end do:
val1 := thesum/ntimes:
state := "Nag_QuasiRandom_Finish":
NAG:-g05ybc(state, seq_type, lnorm, mean, std, iskip, quasi, gf, 'idim' = idim) ;
# No need to free quasi
NAG:-FreeOptions(gf) ;
|
|
|
See Also
|
|
Box G E P and Muller M E (1958) A note on the generation of random normal deviates Ann. Math. Statist. 29 610–611
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.
|
|