# Syntax

C# |
---|

public static void g05ym( int n, int rcord, double[,] quas, int[] iref, out int ifail ) |

Visual Basic |
---|

Public Shared Sub g05ym ( _ n As Integer, _ rcord As Integer, _ quas As Double(,), _ iref As Integer(), _ <OutAttribute> ByRef ifail As Integer _ ) |

Visual C++ |
---|

public: static void g05ym( int n, int rcord, array<double,2>^ quas, array<int>^ iref, [OutAttribute] int% ifail ) |

F# |
---|

static member g05ym : n : int * rcord : int * quas : float[,] * iref : int[] * ifail : int byref -> unit |

#### Parameters

- n
- Type: System..::..Int32
*On entry*: the number of quasi-random numbers required.*Constraint*: ${\mathbf{n}}\ge 0$ and ${\mathbf{n}}+\text{previous number of generated values}\le {2}^{31}-1$.

- rcord
- Type: System..::..Int32
*On entry*: the order in which the generated values are returned.*Constraint*: ${\mathbf{rcord}}=1$ or $2$.

- quas
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, $\mathit{tdquas}$]
**Note:**dim1 must satisfy the constraint:- if ${\mathbf{rcord}}=1$, $\mathrm{dim1}\ge \mathit{idim}$;
- if ${\mathbf{rcord}}=2$, $\mathrm{dim1}\ge {\mathbf{n}}$.

*On exit*: contains the n quasi-random numbers of dimension idim.If ${\mathbf{rcord}}=1$, ${\mathbf{quas}}[i-1,j-1]$ holds the $j$th value for the $i$th dimension.If ${\mathbf{rcord}}=2$, ${\mathbf{quas}}[i-1,j-1]$ holds the $i$th value for the $j$th dimension.

- iref
- Type: array<System..::..Int32>[]()[][]An array of size [$\mathit{liref}$]
*On entry*: contains information on the current state of the sequence.*On exit*: contains updated information on the state of the sequence.

- ifail
- Type: System..::..Int32%
*On exit*: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# 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.

g05ym generates a set of points ${x}^{1},{x}^{2},\dots ,{x}^{N}$ with high uniformity in the $S$-dimensional unit cube ${I}^{S}={\left[0,1\right]}^{S}$.

Let $G$ be a subset of ${I}^{S}$ and define the counting function ${S}_{N}\left(G\right)$ as the number of points ${x}^{i}\in G$. For each $x=\left({x}_{1},{x}_{2},\dots ,{x}_{S}\right)\in {I}^{S}$, let ${G}_{x}$ be the rectangular $S$-dimensional region

with volume ${x}_{1},{x}_{2},\dots ,{x}_{S}$. Then one measure of the uniformity of the points ${x}^{1},{x}^{2},\dots ,{x}^{N}$ is the discrepancy:

which has the form

$${G}_{x}=\left[0,{x}_{1}\right)\times \left[0,{x}_{2}\right)\times \cdots \times \left[0,{x}_{S}\right)$$ |

$${D}_{N}^{*}\left({x}^{1},{x}^{2},\dots ,{x}^{N}\right)=\underset{x\in {I}^{S}}{\mathrm{sup}}\phantom{\rule{0.25em}{0ex}}\left|{S}_{N}\left({G}_{x}\right)-N{x}_{1},{x}_{2},\dots ,{x}_{S}\right|\text{.}$$ |

$${D}_{N}^{*}\left({x}^{1},{x}^{2},\dots ,{x}^{N}\right)\le {C}_{S}{\left(\mathrm{log}\u200aN\right)}^{S}+\mathit{O}\left({\left(\mathrm{log}\u200aN\right)}^{S-1}\right)\text{\hspace{1em} for all \hspace{1em}}N\ge 2\text{.}$$ |

The principal aim in the construction of low-discrepancy sequences is to find sequences of points in ${I}^{S}$ with a bound of this form where the constant ${C}_{S}$ is as small as possible.

The type of low-discrepancy sequence generated by g05ym depends on the initialization method called and can include those proposed by Sobol, Faure or Niederreiter. If the initialization method g05yn was used then the sequence will be scrambled (see [Description] in 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–100Fox B L (1986) Algorithm 647: implementation and relative efficiency of quasirandom sequence generators

*ACM Trans. Math. Software***12(4)**362–376# Error Indicators and Warnings

Errors or warnings detected by the method:

Some error messages may refer to parameters that are dropped from this interface
(LDQUAS) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.

- ${\mathbf{ifail}}=1$
- On entry, either ${\mathbf{n}}<0$ or there have been too many calls to the generator.

- ${\mathbf{ifail}}=2$
- On entry, ${\mathbf{rcord}}\ne 1$ or $2$.

- ${\mathbf{ifail}}=4$
- On entry, ${\mathbf{rcord}}=1$ and ${\mathbf{ldquas}}<\mathit{idim}$.On entry, ${\mathbf{rcord}}=2$ and ${\mathbf{ldquas}}<{\mathbf{n}}$.

- ${\mathbf{ifail}}=5$

- ${\mathbf{ifail}}=-9000$
- An error occured, see message report.
- ${\mathbf{ifail}}=-4000$
- Invalid dimension for array $\u2329\mathit{\text{value}}\u232a$
- ${\mathbf{ifail}}=-8000$
- Negative dimension for array $\u2329\mathit{\text{value}}\u232a$
- ${\mathbf{ifail}}=-6000$
- Invalid Parameters $\u2329\mathit{\text{value}}\u232a$

# Accuracy

Not applicable.

# Parallelism and Performance

None.

# Further Comments

None.

# Example

In this example the number of dimensions $S$ is set to $8$.

Example program (C#): g05yme.cs