# NAG CL Interfaceg05rfc (copula_​frank_​bivar)

Settings help

CL Name Style:

## 1Purpose

g05rfc generates pseudorandom uniform bivariates with joint distribution of a Frank Archimedean copula.

## 2Specification

 #include
 void g05rfc (Nag_OrderType order, Integer state[], double theta, Integer n, double x[], Integer pdx, Integer sdx, NagError *fail)
The function may be called by the names: g05rfc, nag_rand_copula_frank_bivar or nag_rand_bivariate_copula_frank.

## 3Description

Generates pseudorandom uniform bivariates $\left\{{u}_{1},{u}_{2}\right\}\in {\left[0,1\right]}^{2}$ whose joint distribution is the Frank Archimedean copula ${C}_{\theta }$ with parameter $\theta$, given by
 $Cθ = - 1θ ln[1+ ( e -θu1 -1) ( e -θu2 -1) e-θ-1 ] , θ ∈ (-∞,∞) ∖ {0}$
with the special cases:
• ${C}_{-\infty }=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({u}_{1}+{u}_{2}-1,0\right)$, the Fréchet–Hoeffding lower bound;
• ${C}_{0}={u}_{1}{u}_{2}$, the product copula;
• ${C}_{\infty }=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({u}_{1},{u}_{2}\right)$, the Fréchet–Hoeffding upper bound.
The generation method uses conditional sampling.
One of the initialization functions g05kfc (for a repeatable sequence if computed sequentially) or g05kgc (for a non-repeatable sequence) must be called prior to the first call to g05rfc.

## 4References

Nelsen R B (2006) An Introduction to Copulas (2nd Edition) Springer Series in Statistics

## 5Arguments

1: $\mathbf{order}$Nag_OrderType Input
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 ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2: $\mathbf{state}\left[\mathit{dim}\right]$Integer Communication Array
Note: the dimension, $\mathit{dim}$, of this array is dictated by the requirements of associated functions that must have been previously called. This array MUST be the same array passed as argument state in the previous call to nag_rand_init_repeatable (g05kfc) or nag_rand_init_nonrepeatable (g05kgc).
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
3: $\mathbf{theta}$double Input
On entry: $\theta$, the copula parameter.
4: $\mathbf{n}$Integer Input
On entry: $n$, the number of bivariates to generate.
Constraint: ${\mathbf{n}}\ge 0$.
5: $\mathbf{x}\left[{\mathbf{pdx}}×{\mathbf{sdx}}\right]$double Output
Note: where ${\mathbf{X}}\left(i,j\right)$ appears in this document, it refers to the array element
• ${\mathbf{x}}\left[\left(j-1\right)×{\mathbf{pdx}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{x}}\left[\left(i-1\right)×{\mathbf{pdx}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On exit: the $n$ bivariate uniforms with joint distribution described by ${C}_{\theta }$, with ${\mathbf{X}}\left(i,j\right)$ holding the $i$th value for the $j$th dimension if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$ and the $j$th value for the $i$th dimension if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
6: $\mathbf{pdx}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdx}}\ge {\mathbf{n}}$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdx}}\ge 2$.
7: $\mathbf{sdx}$Integer Input
On entry: the secondary dimension of x.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{sdx}}\ge 2$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{sdx}}\ge {\mathbf{n}}$.
8: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
NE_INT_2
On entry, pdx must be at least $⟨\mathit{\text{value}}⟩$: ${\mathbf{pdx}}=⟨\mathit{\text{value}}⟩$.
On entry, sdx must be at least $⟨\mathit{\text{value}}⟩$: ${\mathbf{sdx}}=⟨\mathit{\text{value}}⟩$.
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.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_INVALID_STATE
On entry, corrupt state argument.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

Not applicable.

## 8Parallelism and Performance

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

In practice, the need for numerical stability restricts the range of $\theta$ such that:
• if $\theta <\mathrm{ln}{\epsilon }_{s}$, the function returns pseudorandom uniform variates with ${C}_{-\infty }$ joint distribution;
• if $|\theta |<1.0×{10}^{-6}$, the function returns pseudorandom uniform variates with ${C}_{0}$ joint distribution;
• if $\theta >\mathrm{ln}\epsilon$, the function returns pseudorandom uniform variates with ${C}_{\infty }$ joint distribution;
where ${\epsilon }_{s}$ is the safe-range parameter, the value of which is returned by X02AMC; and $\epsilon$ is the machine precision returned by X02AJC.

## 10Example

This example generates thirteen variates for copula ${C}_{-12.0}$.

### 10.1Program Text

Program Text (g05rfce.c)

None.

### 10.3Program Results

Program Results (g05rfce.r)