# NAG FL Interfaceg05ztf (field_​fracbm_​generate)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

g05ztf produces realizations of a fractional Brownian motion, using the circulant embedding method. The square roots of the eigenvalues of the extended covariance matrix (or embedding matrix) need to be input, and can be calculated using g05znf.

## 2Specification

Fortran Interface
 Subroutine g05ztf ( ns, s, m, xmax, h, lam, rho, z, xx,
 Integer, Intent (In) :: ns, s, m Integer, Intent (Inout) :: state(*), ifail Real (Kind=nag_wp), Intent (In) :: xmax, h, lam(m), rho Real (Kind=nag_wp), Intent (Out) :: z(ns+1,s), xx(ns+1)
#include <nag.h>
 void g05ztf_ (const Integer *ns, const Integer *s, const Integer *m, const double *xmax, const double *h, const double lam[], const double *rho, Integer state[], double z[], double xx[], Integer *ifail)
The routine may be called by the names g05ztf or nagf_rand_field_fracbm_generate.

## 3Description

The routines g05znf and g05ztf are used to simulate a fractional Brownian motion process with Hurst parameter $H$ over an interval $\left[0,{x}_{\mathrm{max}}\right]$, using a set of equally spaced points. Fractional Brownian motion itself cannot be simulated directly using this method, since it is not a stationary Gaussian random field; however its increments can be simulated like a stationary Gaussian random field. The circulant embedding method is described in the documentation for g05znf.
g05ztf takes the square roots of the eigenvalues of the embedding matrix as returned by g05znf when ${\mathbf{icov1}}=14$, and its size $M$, as input and outputs $S$ realizations of the fractional Brownian motion in $Z$.
One of the initialization routines g05kff (for a repeatable sequence if computed sequentially) or g05kgf (for a non-repeatable sequence) must be called prior to the first call to g05ztf.
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
Schlather M (1999) Introduction to positive definite functions and to unconditional simulation of random fields Technical Report ST 99–10 Lancaster University
Wood A T A and Chan G (1994) Simulation of stationary Gaussian processes in ${\left[0,1\right]}^{d}$ Journal of Computational and Graphical Statistics 3(4) 409–432

## 5Arguments

1: $\mathbf{ns}$Integer Input
On entry: the number of steps (points) to be generated in realizations of the increments of the fractional Brownian motion. This must be the same value as supplied to g05znf when calculating the eigenvalues of the embedding matrix.
Note: in the context of fractional Brownian motion, ns represents the number of steps from a zero starting state. Realizations returned in z include this starting state and so ${\mathbf{ns}}+1$ values are returned for each realization.
Constraint: ${\mathbf{ns}}\ge 1$.
2: $\mathbf{s}$Integer Input
On entry: $S$, the number of realizations of the fractional Brownian motion to simulate.
Constraint: ${\mathbf{s}}\ge 1$.
3: $\mathbf{m}$Integer Input
On entry: the size, $M$, of the embedding matrix, as returned by g05zmf or g05znf.
Constraint: ${\mathbf{m}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,2\left({\mathbf{ns}}-1\right)\right)$.
4: $\mathbf{xmax}$Real (Kind=nag_wp) Input
On entry: the upper bound for the interval over which the fractional Brownian motion is to be simulated, as input to g05zmf or g05znf.
Constraint: ${\mathbf{xmax}}>0.0$.
5: $\mathbf{h}$Real (Kind=nag_wp) Input
On entry: the Hurst parameter, $H$, for the fractional Brownian motion. This must be the same value as supplied to g05znf in ${\mathbf{params}}\left(1\right)$, when the eigenvalues of the embedding matrix were calculated.
Constraint: $0.0<{\mathbf{h}}<1.0$.
6: $\mathbf{lam}\left({\mathbf{m}}\right)$Real (Kind=nag_wp) array Input
On entry: contains the square roots of the eigenvalues of the embedding matrix, as returned by g05zmf or g05znf.
Constraint: ${\mathbf{lam}}\left(\mathit{i}\right)\ge 0$, for $\mathit{i}=1,2,\dots ,{\mathbf{m}}$.
7: $\mathbf{rho}$Real (Kind=nag_wp) Input
On entry: indicates the scaling of the covariance matrix, as returned by g05zmf or g05znf.
Constraint: $0.0<{\mathbf{rho}}\le 1.0$.
8: $\mathbf{state}\left(*\right)$Integer array Communication Array
Note: the actual argument supplied must be the array state supplied to the initialization routines g05kff or g05kgf.
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
9: $\mathbf{z}\left({\mathbf{ns}}+1,{\mathbf{s}}\right)$Real (Kind=nag_wp) array Output
On exit: contains the realizations of the fractional Brownian motion, $Z$. The $\mathit{j}$th realization, for the $\mathit{i}$th point ${\mathbf{xx}}\left(\mathit{i}\right)$, is stored in ${\mathbf{z}}\left(\mathit{i},\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{s}}$ and $\mathit{i}=1,2,\dots ,{\mathbf{ns}}+1$.
10: $\mathbf{xx}\left({\mathbf{ns}}+1\right)$Real (Kind=nag_wp) array Output
On exit: the points at which values of the fractional Brownian motion are output. The first point is always zero, and the subsequent ns points represent the equispaced steps towards the last point, xmax. Note that in g05zmf and g05znf, the returned ns sample points are the mid-points of the grid returned in xx here.
11: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{ns}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ns}}\ge 1$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{s}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{s}}\ge 1$.
${\mathbf{ifail}}=3$
On entry, ${\mathbf{m}}=⟨\mathit{\text{value}}⟩$, and ${\mathbf{ns}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{m}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,2\left({\mathbf{ns}}-1\right)\right)$.
${\mathbf{ifail}}=4$
On entry, ${\mathbf{xmax}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{xmax}}>0.0$.
${\mathbf{ifail}}=5$
On entry, ${\mathbf{h}}=⟨\mathit{\text{value}}⟩$.
Constraint: $0.0<{\mathbf{h}}<1.0$.
${\mathbf{ifail}}=6$
On entry, at least one element of lam was negative.
Constraint: all elements of lam must be non-negative.
${\mathbf{ifail}}=7$
On entry, ${\mathbf{rho}}=⟨\mathit{\text{value}}⟩$.
Constraint: $0.0<{\mathbf{rho}}\le 1.0$.
${\mathbf{ifail}}=8$
On entry, state vector has been corrupted or not initialized.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Not applicable.

## 8Parallelism and Performance

g05ztf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g05ztf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

None.

## 10Example

This example calls g05ztf to generate $5$ realizations of a fractional Brownian motion over $10$ steps from $x=0.0$ to $x=2.0$ using eigenvalues generated by g05znf with ${\mathbf{icov1}}=14$.

### 10.1Program Text

Program Text (g05ztfe.f90)

### 10.2Program Data

Program Data (g05ztfe.d)

### 10.3Program Results

Program Results (g05ztfe.r)