PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_rand_field_fracbm_generate (g05zt)
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
over an interval
, 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
, and its size
, as input and outputs
realizations of the fractional Brownian motion in
.
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 Journal of Computational and Graphical Statistics 3(4) 409–432
Parameters
Compulsory Input Parameters
- 1:
– 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
values are returned for each realization..
Constraint:
.
- 2:
– int64int32nag_int scalar
-
, the number of realizations of the fractional Brownian motion to simulate.
Constraint:
.
- 3:
– 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:
.
- 4:
– double scalar
-
The Hurst parameter,
, for the fractional Brownian motion. This must be the same value as supplied to
nag_rand_field_1d_predef_setup (g05zn) in
, when the eigenvalues of the embedding matrix were calculated.
Constraint:
.
- 5:
– 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:
, for .
- 6:
– double scalar
-
Constraint:
.
- 7:
– 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:
– int64int32nag_int scalar
-
Default:
the dimension of the array
lam.
Constraint:
.
Output Parameters
- 1:
– int64int32nag_int array
-
Contains updated information on the state of the generator.
- 2:
– double array
-
Contains the realizations of the fractional Brownian motion, .
The th realization, for the th point , is stored in , for and .
- 3:
– 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:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: .
-
-
On entry, at least one element of
lam was negative.
Constraint: all elements of
lam must be non-negative.
-
-
Constraint: .
-
-
On entry,
state vector has been corrupted or not initialized.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Not applicable.
Further Comments
None.
Example
This example calls
nag_rand_field_fracbm_generate (g05zt) to generate
realizations of a fractional Brownian motion over
steps from
to
using eigenvalues generated by
nag_rand_field_1d_predef_setup (g05zn) with
.
Open in the MATLAB editor:
g05zt_example
function g05zt_example
fprintf('g05zt example results\n\n');
xmax = 2;
ns = int64(10);
icorr = int64(2);
h = 0.35;
icov1 = int64(14);
np = int64(2);
xmin = 0;
var = 1;
params = [h, xmax/double(ns)];
[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);
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
genid = int64(1);
subid = int64(1);
seed = [int64(14965)];
[state, ifail] = g05kf( ...
genid, subid, seed);
s = int64(5);
[state, z, yy, ifail] = g05zt( ...
ns, s, xmax, h, lam(1:m), rho, state);
rlabs = cell(ns+1, 1);
for i=1:ns+1
rlabs{i} = sprintf('%6.1f', yy(i));
end
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)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015