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)

Purpose

nag_rand_field_fracbm_generate (g05zt) produces realisations of a fractional Brownian motion, using the circulant embedding method. The square roots of the extended covariance matrix (or embedding matrix) need to be input, and can be calculated using nag_rand_field_1d_user_setup (g05zm) or 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_user_setup (g05zm) or 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 parameter HH over an interval [0,xmax][0,xmax], using a set of equally spaced gridpoints. 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_user_setup (g05zm) or 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_user_setup (g05zm) or nag_rand_field_1d_predef_setup (g05zn), and its size MM, as input and outputs SS realisations of the fractional Brownian motion in ZZ.
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,1]d[0,1]d Journal of Computational and Graphical Statistics 3(4) 409–432

Parameters

Compulsory Input Parameters

1:     ns – int64int32nag_int scalar
The number of sample points (grid points) to be generated in realisations of the increments of the fractional Brownian motion. This must be the same value as supplied to nag_rand_field_1d_user_setup (g05zm) or nag_rand_field_1d_predef_setup (g05zn) when calculating the eigenvalues of the embedding matrix.
Constraint: ns1ns1.
2:     s – int64int32nag_int scalar
The number of realisations of the fractional Brownian motion to simulate.
Constraint: s1s1.
3:     xmax – double scalar
The upper bound for the interval over which the fractional Brownian motion is to be simulated, as returned by nag_rand_field_1d_user_setup (g05zm) or nag_rand_field_1d_predef_setup (g05zn).
Constraint: xmax > 0.0xmax>0.0.
4:     h – double scalar
The Hurst parameter for the fractional Brownian motion. This must be the same value as supplied to nag_rand_field_1d_user_setup (g05zm) or nag_rand_field_1d_predef_setup (g05zn) when calculating the eigenvalues of the embedding matrix.
Constraint: 0.0 < h < 1.00.0<h<1.0.
5:     lam(m) – double array
m, the dimension of the array, must satisfy the constraint mmax (1,2(ns1))mmax(1,2(ns-1)).
Contains the square roots of the eigenvalues of the embedding matrix, as returned by nag_rand_field_1d_predef_setup (g05zn).
Constraint: lam(i) = 0lami=0, i = 1,2,,mi=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.00.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 of the embedding matrix, as returned by nag_rand_field_1d_user_setup (g05zm) or nag_rand_field_1d_predef_setup (g05zn).
Constraint: mmax (1,2(ns1))mmax(1,2(ns-1)).

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     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 updated information on the state of the generator.
2:     z(ns + 1ns+1,s) – double array
Contains the realisations of the fractional Brownian motion. Each column of z contains one realisation of the fractional Brownian motion, with z(i,j)zij, for j = 1,2,,sj=1,2,,s, corresponding to the gridpoint xx(i)xxi .
3:     xx(ns + 1ns+1) – double array
The gridpoints at which values of the fractional Brownian motion are output. The first gridpoint is always zero, and the subsequent ns gridpoints represent the equispaced steps towards the last gridpoint, 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 = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
Constraint: ns1ns1.
  ifail = 2ifail=2
Constraint: s1s1.
  ifail = 3ifail=3
Constraint: mmax (1,2(ns1))mmax(1,2(ns-1)).
  ifail = 4ifail=4
Constraint: xmax > 0.0xmax>0.0.
  ifail = 5ifail=5
Constraint: 0.0 < h < 1.00.0<h<1.0.
  ifail = 6ifail=6
On entry, at least one element of lam was negative.
Constraint: all elements of lam must be non-negative.
  ifail = 7ifail=7
Constraint: 0.0 < rho1.00.0<rho1.0.
  ifail = 8ifail=8
On entry, state vector has been corrupted or not initialized.

Accuracy

Not applicable.

Further Comments

None.

Example

function nag_rand_field_fracbm_generate_example
h = 0.35;
xmax = 2;
ns = int64(10);
icorr = int64(2);
s = int64(5);
% Set fixed problem specifications for simulating fractional Brownian motion
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] = ...
    nag_rand_field_1d_predef_setup(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] = nag_rand_init_repeat(genid, subid, seed);

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

% Display random field results
title = 'Fractional Brownian motion realisations (x coordinate first):';
% 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

[ifail] = ...
   nag_file_print_matrix_real_gen_comp('g', 'n', z, 'f10.5', title, 'c', rlabs, 'i', {''}, int64(80), int64(0))
 

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

ifail =

                    0


function g05zt_example
h = 0.35;
xmax = 2;
ns = int64(10);
icorr = int64(2);
s = int64(5);
% Set fixed problem specifications for simulating fractional Brownian motion
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.
[state, z, yy, ifail] = g05zt(ns, s, xmax, h, lam(1:m), rho, state);

% Display random field results
title = 'Fractional Brownian motion realisations (x coordinate first):';
% 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

[ifail] = ...
   x04cb('g', 'n', z, 'f10.5', title, 'c', rlabs, 'i', {''}, int64(80), int64(0))
 

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

ifail =

                    0



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–2013