uses a Brownian bridge algorithm to construct sample paths for a free or non-free Wiener process. The initialization function nag_rand_bb_init (g05xa)
must be called prior to the first call to nag_rand_bb (g05xb)
For details on the Brownian bridge algorithm and the bridge construction order see Brownian Bridge
in the G05 Chapter Introduction and Description
in nag_rand_bb_init (g05xa)
. Recall that the terms Wiener process (or free Wiener process) and Brownian motion are often used interchangeably, while a non-free Wiener process (also known as a Brownian bridge process) refers to a process which is forced to terminate at a given point.
the following variable is used in the parameter descriptions:
, the length of the array times
passed to the initialization function nag_rand_bb_init (g05xa)
This example calls nag_rand_bb (g05xb)
, nag_rand_bb_init (g05xa)
and nag_rand_bb_make_bridge_order (g05xe)
to generate two sample paths of a three-dimensional non-free Wiener process. The process starts at zero and each sample path terminates at the point
. Quasi-random numbers are used to construct the sample paths.
fprintf('g05xb example results\n\n');
[bgord,t0,tend,ntimes,intime,nmove,move] = get_bridge_init_data();
[times, ifail] = g05xe( ...
t0, tend, intime, move, 'bgord', bgord);
[rcomm, ifail] = g05xa( ...
t0, tend, times);
[npaths, d, start, term, c] = get_bridge_gen_data();
[z] = get_z(npaths, d, ntimes);
[z, b, ifail] = g05xb( ...
npaths, start, term, z, c, rcomm);
for i = 1:npaths
fprintf('Weiner Path %d, %d time steps, %d dimensions\n', i, ntimes+1, d);
w = transpose(reshape(b(:,i), d, ntimes+1));
ifail = x04ca('G', ' ', w, '');
function [bgord,t0,tend,ntimes,intime,nmove,move] = get_bridge_init_data()
t0 = 0;
n = 10;
ntimes = int64(n);
intime = 1:n + t0;
tend = t0 + n + 1;
move = zeros(nmove, 1, 'int64');
bgord = int64(3);
function [npaths,d,start,term,c] = get_bridge_gen_data();
npaths = int64(2);
d = 3;
start = zeros(d, 1);
term = [1, 0.5, 0];
c = [ 6, 1, -0.2;
1, 5, 0.3;
-0.2, 0.3, 4];
[c, info] = f07fd('l', c);
function [z] = get_z(npaths, d, ntimes)
a = int64(1);
idim = d*(ntimes+1-a);
state = initialize_prng(int64(6), int64(0), [int64(1023401)]);
[iref, state] = initialize_scrambled_qrng(int64(1), int64(2), ...
xmean = zeros(idim, 1);
std = ones(idim, 1);
[z, iref, ifail] = g05yj( ...
xmean, std, npaths, iref);
z = z';
function [state] = initialize_prng(genid, subid, seed)
[state, ifail] = g05kf( ...
genid, subid, seed);
function [iref, state] = initialize_scrambled_qrng(genid,stype,idim,state)
iskip = int64(0);
nsdigits = int64(32);
[iref, state, ifail] = g05yn( ...
genid, stype, int64(idim), iskip, ...