hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_rand_field_fracbm_generate (g05zt)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_rand_field_fracbm_generate (g05zt) 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 nag_rand_field_1d_predef_setup (g05zn).

Syntax

[state, z, xx, ifail] = g05zt(ns, s, xmax, h, lam, rho, state, 'm', m)
[state, z, xx, ifail] = nag_rand_field_fracbm_generate(ns, s, xmax, h, lam, rho, state, 'm', m)

Description

The functions nag_rand_field_1d_predef_setup (g05zn) and nag_rand_field_fracbm_generate (g05zt) are used to simulate a fractional Brownian motion process with Hurst argument H over an interval 0,xmax, 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 nag_rand_field_1d_predef_setup (g05zn).
nag_rand_field_fracbm_generate (g05zt) takes the square roots of the eigenvalues of the embedding matrix as returned by nag_rand_field_1d_predef_setup (g05zn) when icov1=14, and its size M, as input and outputs S realizations of the fractional Brownian motion in Z.
One of the initialization functions nag_rand_init_repeat (g05kf) (for a repeatable sequence if computed sequentially) or nag_rand_init_nonrepeat (g05kg) (for a non-repeatable sequence) must be called prior to the first call to nag_rand_field_fracbm_generate (g05zt).

References

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 0,1d Journal of Computational and Graphical Statistics 3(4) 409–432

Parameters

Compulsory Input Parameters

1:     ns int64int32nag_int scalar
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 nag_rand_field_1d_predef_setup (g05zn) 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 ns+1 values are returned for each realization..
Constraint: ns1.
2:     s int64int32nag_int scalar
S, the number of realizations of the fractional Brownian motion to simulate.
Constraint: s1.
3:     xmax – double scalar
The upper bound for the interval over which the fractional Brownian motion is to be simulated, as input to nag_rand_field_1d_user_setup (g05zm) or nag_rand_field_1d_predef_setup (g05zn).
Constraint: xmax>0.0.
4:     h – double scalar
The Hurst parameter, H, for the fractional Brownian motion. This must be the same value as supplied to nag_rand_field_1d_predef_setup (g05zn) in params1, when the eigenvalues of the embedding matrix were calculated.
Constraint: 0.0<h<1.0.
5:     lamm – double array
Contains the square roots of the eigenvalues of the embedding matrix, as returned by nag_rand_field_1d_user_setup (g05zm) or nag_rand_field_1d_predef_setup (g05zn).
Constraint: lami0, for i=1,2,,m.
6:     rho – double scalar
Indicates the scaling of the covariance matrix, as returned by nag_rand_field_1d_user_setup (g05zm) or nag_rand_field_1d_predef_setup (g05zn).
Constraint: 0.0<rho1.0.
7:     state: int64int32nag_int array
Note: the actual argument supplied must be the array state supplied to the initialization routines nag_rand_init_repeat (g05kf) or nag_rand_init_nonrepeat (g05kg).
Contains information on the selected base generator and its current state.

Optional Input Parameters

1:     m int64int32nag_int scalar
Default: the dimension of the array lam.
The size, M, of the embedding matrix, as returned by nag_rand_field_1d_user_setup (g05zm) or nag_rand_field_1d_predef_setup (g05zn).
Constraint: mmax1,2ns-1.

Output Parameters

1:     state: int64int32nag_int array
Contains updated information on the state of the generator.
2:     zns+1s – double array
Contains the realizations of the fractional Brownian motion, Z. The jth realization, for the ith point xxi, is stored in zij, for j=1,2,,s and i=1,2,,ns+1.
3:     xxns+1 – double array
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 nag_rand_field_1d_user_setup (g05zm) and nag_rand_field_1d_predef_setup (g05zn), the returned ns sample points are the mid-points of the grid returned in xx here.
4:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
Constraint: ns1.
   ifail=2
Constraint: s1.
   ifail=3
Constraint: mmax1,2ns-1.
   ifail=4
Constraint: xmax>0.0.
   ifail=5
Constraint: 0.0<h<1.0.
   ifail=6
On entry, at least one element of lam was negative.
Constraint: all elements of lam must be non-negative.
   ifail=7
Constraint: 0.0<rho1.0.
   ifail=8
On entry, state vector has been corrupted or not initialized.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Not applicable.

Further Comments

None.

Example

This example calls nag_rand_field_fracbm_generate (g05zt) to generate 5 realizations of a fractional Brownian motion over 10 steps from x=0.0 to x=2.0 using eigenvalues generated by nag_rand_field_1d_predef_setup (g05zn) with icov1=14.
function g05zt_example


fprintf('g05zt example results\n\n');

% Upper bound for interval
xmax = 2;
% Number of sample points
ns   = int64(10);
% Scaling factor, rho = 1.
icorr = int64(2);

% Set fixed problem specifications for simulating fractional Brownian motion
h     = 0.35;
icov1 = int64(14);
np    = int64(2);
xmin  = 0;
var   = 1;
params = [h, xmax/double(ns)];

% Get square roots of the eigenvalues of the embedding matrix
[lam, xx, m, approx, rho, icount, eig, ifail] = ...
  g05zn( ...
         ns, xmin, xmax, var, icov1, params, ...
         'icorr', icorr, 'maxm', int64(2048));

fprintf('\nSize of embedding matrix = %d\n\n', m);

% Display approximation information if approximation used
if approx == 1
  fprintf('Approximation required\n\n');
  fprintf('rho = %10.5f\n', rho);
  fprintf('eig = %10.5f%10.5f%10.5f\n', eig(1:3));
  fprintf('icount = %d\n', icount);
else
  fprintf('Approximation not required\n\n');
end

% Initialize state array
genid = int64(1);
subid = int64(1);
seed  = [int64(14965)];
[state, ifail] = g05kf( ...
                        genid, subid, seed);

% Compute s fractional Brownian Motion realisations.
s    = int64(5);
[state, z, yy, ifail] = g05zt( ...
                               ns, s, xmax, h, lam(1:m), rho, state);

% Display random field results
% Set row labels to mesh points (column label is realisation number).
rlabs = cell(ns+1, 1);
for i=1:ns+1
  rlabs{i} = sprintf('%6.1f', yy(i));
end

% Matrix printing parameters
mtitle = 'Fractional Brownian motion realisations (x coordinate first):';
matrix = 'General';
diag   = 'Non-unit';
fmt    = 'f10.5';
rlabel = 'Character';
clabel = 'Integer';
clabs  = {' '};
ncols  = int64(80);
indent = int64(0);

[ifail] = x04cb( ...
                 matrix, diag, z, fmt, mtitle, rlabel, rlabs, clabel, ...
                 clabs, ncols, indent);


g05zt example results


Size of embedding matrix = 32

Approximation not required

 Fractional Brownian motion realisations (x coordinate first):
              1         2         3         4         5
 0.0    0.00000   0.00000   0.00000   0.00000   0.00000
 0.2   -0.52650  -0.16159  -0.96224  -0.40096   0.65803
 0.4   -1.81085  -0.85811  -1.43661   0.03947   0.99671
 0.6   -1.65690  -0.74802  -0.61733  -0.34685   0.05141
 0.8   -1.72240  -0.14958   0.14996   0.18134   0.26567
 1.0   -2.20349   0.46219   0.70982   0.66405   0.40706
 1.2   -2.38542   0.52085   0.36330   0.31831   0.81515
 1.4   -3.13939   0.68433   0.79826  -0.35408   1.12296
 1.6   -3.54602   0.64413   0.85751  -0.39303   1.14220
 1.8   -4.09082   1.67048   0.06038   0.30181   1.30350
 2.0   -2.97487   1.72275  -0.67253  -0.07439   1.57169

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015