NAG CL Interface
g05xdc (bb_inc)
1
Purpose
g05xdc computes scaled increments of sample paths of a free or non-free Wiener process, where the sample paths are constructed by a Brownian bridge algorithm. The initialization function
g05xcc must be called prior to the first call to
g05xdc.
2
Specification
void |
g05xdc (Nag_OrderType order,
Integer npaths,
Integer d,
Integer a,
const double diff[],
double z[],
Integer pdz,
const double c[],
Integer pdc,
double b[],
Integer pdb,
const double rcomm[],
NagError *fail) |
|
The function may be called by the names: g05xdc or nag_rand_bb_inc.
3
Description
For details on the Brownian bridge algorithm and the bridge construction order see
Section 2.6 in the
G05 Chapter Introduction and
Section 3 in
g05xcc. 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.
Fix two times , let be any set of time points satisfying , and let , , denote a -dimensional Wiener sample path at these time points.
The Brownian bridge increments generator uses the Brownian bridge algorithm to construct sample paths for the (free or non-free) Wiener process
, and then uses this to compute the
scaled Wiener increments
The example program in
Section 10 shows how these increments can be used to compute a numerical solution to a stochastic differential equation (SDE) driven by a (free or non-free) Wiener process.
4
References
Glasserman P (2004) Monte Carlo Methods in Financial Engineering Springer
5
Arguments
Note: the following variable is used in the parameter descriptions:
, the length of the array
times passed to the initialization function
g05xcc.
-
1:
– Nag_OrderType
Input
-
On entry: the
order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by
. See
Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint:
or .
-
2:
– Integer
Input
-
On entry: the number of Wiener sample paths.
Constraint:
.
-
3:
– Integer
Input
-
On entry: the dimension of each Wiener sample path.
Constraint:
.
-
4:
– Integer
Input
-
On entry: if
, a free Wiener process is created and
diff is ignored.
If
, a non-free Wiener process is created where
diff is the difference between the terminal value and the starting value of the process.
Constraint:
or .
-
5:
– const double
Input
-
On entry: the difference between the terminal value and starting value of the Wiener process. If
,
diff is ignored.
-
6:
– double
Input/Output
-
Note: the dimension,
dim, of the array
z
must be at least
- when
;
- when
.
The
th element of the matrix
is stored in
- when ;
- when .
On entry: the Normal random numbers used to construct the sample paths.
If quasi-random numbers are used, the -dimensional quasi-random points should be stored in successive rows of .
On exit: the Normal random numbers premultiplied by
c.
-
7:
– Integer
Input
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
z.
Constraints:
- if , ;
- if , .
-
8:
– const double
Input
-
Note: the dimension,
dim, of the array
c
must be at least
.
The th element of the matrix is stored in .
On entry: the lower triangular Cholesky factorization such that gives the covariance matrix of the Wiener process. Elements of above the diagonal are not referenced.
-
9:
– Integer
Input
-
On entry: the stride separating matrix row elements in the array
c.
Constraint:
.
-
10:
– double
Output
-
Note: the dimension,
dim, of the array
b
must be at least
- when
;
- when
.
The
th element of the matrix
is stored in
- when ;
- when .
On exit: the scaled Wiener increments.
Let denote the th dimension of the th point of the th sample path where , and . The increment is stored at .
-
11:
– Integer
Input
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
b.
Constraints:
- if , ;
- if , .
-
12:
– const double
Communication Array
-
Note: the dimension,
, of this array is dictated by the requirements of associated functions that must have been previously called. This array MUST be the same array passed as argument
rcomm in the previous call to
g05xcc or
g05xdc.
On entry: communication array as returned by the last call to
g05xcc or
g05xdc. This array MUST NOT be directly modified.
-
13:
– NagError *
Input/Output
-
The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
6
Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
- NE_ARRAY_SIZE
-
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_ILLEGAL_COMM
-
On entry,
rcomm was not initialized or has been corrupted.
- NE_INT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INTERNAL_ERROR
-
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
See
Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library CL Interface for further information.
7
Accuracy
Not applicable.
8
Parallelism and Performance
g05xdc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g05xdc 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 function. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
None.
10
Example
The scaled Wiener increments produced by this function can be used to compute numerical solutions to stochastic differential equations (SDEs) driven by (free or non-free) Wiener processes. Consider an SDE of the form
on the interval
where
is a (free or non-free) Wiener process and
and
are suitable functions. A numerical solution to this SDE can be obtained by the Euler–Maruyama method. For any discretization
of
, set
for
so that
is an approximation to
. The scaled Wiener increments produced by
g05xdc can be used in the
Euler–Maruyama scheme outlined above by writing
The following example program uses this method to solve the SDE for geometric Brownian motion
where
is a Wiener process, and compares the results against the analytic solution
Quasi-random variates are used to construct the Wiener increments.
10.1
Program Text
10.2
Program Data
None.
10.3
Program Results