﻿g05rd Method
g05rd sets up a reference vector and generates an array of pseudorandom numbers from a Normal (Gaussian) copula with covariance matrix C.

# Syntax

C#
```public static void g05rd(
int mode,
int n,
int m,
double[,] c,
double[] r,
G05..::.G05State g05state,
double[,] x,
out int ifail
)```
Visual Basic (Declaration)
```Public Shared Sub g05rd ( _
mode As Integer, _
n As Integer, _
m As Integer, _
c As Double(,), _
r As Double(), _
g05state As G05..::.G05State, _
x As Double(,), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void g05rd(
int mode,
int n,
int m,
array<double,2>^ c,
array<double>^ r,
G05..::.G05State^ g05state,
array<double,2>^ x,
[OutAttribute] int% ifail
)```
F#
```static member g05rd :
mode:int *
n:int *
m:int *
c:float[,] *
r:float[] *
g05state:G05..::.G05State *
x:float[,] *
ifail:int byref -> unit
```

#### Parameters

mode
Type: System..::.Int32
On entry: a code for selecting the operation to be performed by the method.
mode=0
Set up reference vector only.
mode=1
Generate variates using reference vector set up in a prior call to g05rd.
mode=2
Set up reference vector and generate two-way table.
Constraint: mode=0, 1 or 2.
n
Type: System..::.Int32
On entry: n, the number of random variates required.
Constraint: n0.
m
Type: System..::.Int32
On entry: m, the number of dimensions of the distribution.
Constraint: m>0.
c
Type: array< System..::.Double ,2>[,](,)[,]
An array of size [ldc, m]
Note: ldc must satisfy the constraint: ldcm
On entry: the covariance matrix of the distribution. Only the upper triangle need be set.
Constraint: C must be positive semi-definite to machine precision
r
Type: array< System..::.Double >[]()[]
An array of size [lr]
Note: lr must satisfy the constraint: lrm×m+1+1
On entry: if mode=1, the reference vector as set up by g05rd in a previous call with mode=0 or 2.
On exit: if mode=0 or 2, the reference vector that can be used in subsequent calls to g05rd with mode=1.
g05state
Type: NagLibrary..::.G05..::.G05State
An object of type G05.G05State.
x
Type: array< System..::.Double ,2>[,](,)[,]
An array of size [ldx, m]
Note: ldx must satisfy the constraint: ldxn
On exit: the array of values from a multivariate Gaussian copula, with x[i-1,j-1] holding the jth dimension for the ith variate.
ifail
Type: System..::.Int32 %
On exit: ifail=0 unless the method detects an error (see [Error Indicators and Warnings]).

# Accuracy

See [Section ] in g05rz for an indication of the accuracy of the underlying multivariate Normal distribution.