NAG Library Routine Document
G05XDF
Note: before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.
1 Purpose
G05XDF 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 routine
G05XCF must be called prior to the first call to G05XDF.
2 Specification
SUBROUTINE G05XDF (
NPATHS,
RCORD,
D,
A,
DIFF,
Z,
LDZ,
C,
LDC,
B,
LDB,
RCOMM,
IFAIL)
INTEGER
NPATHS, RCORD, D, A, LDZ, LDC, LDB, IFAIL
REAL (KIND=nag_wp)
DIFF(D), Z(LDZ,*), C(LDC,*), B(LDB,*), RCOMM(*)
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 G05XCF. 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 9 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 Parameters
Note: the following variable is used in the parameter descriptions:
, the length of the array
TIMES passed to the initialization routine
G05XCF.
- 1: NPATHS – INTEGERInput
On entry: the number of Wiener sample paths.
Constraint:
.
- 2: RCORD – INTEGERInput
On entry: the order in which Normal random numbers are stored in
Z and in which the generated values are returned in
B.
Constraint:
or .
- 3: D – INTEGERInput
On entry: the dimension of each Wiener sample path.
Constraint:
.
- 4: A – INTEGERInput
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: DIFF(D) – REAL (KIND=nag_wp) arrayInput
On entry: the difference between the terminal value and starting value of the Wiener process. If
,
DIFF is ignored.
- 6: Z(LDZ,) – REAL (KIND=nag_wp) arrayInput/Output
-
Note: the second dimension of the array
Z
must be at least
if
and at least
if
.
On entry: the Normal random numbers used to construct the sample paths.
If
and quasi-random numbers are used, the
, where
-dimensional quasi-random points should be stored in successive columns of
Z.
If
and quasi-random numbers are used, the
, where
-dimensional quasi-random points should be stored in successive rows of
Z.
On exit: the Normal random numbers premultiplied by
C.
- 7: LDZ – INTEGERInput
On entry: the first dimension of the array
Z as declared in the (sub)program from which G05XDF is called.
Constraints:
- if , ;
- if , .
- 8: C(LDC,) – REAL (KIND=nag_wp) arrayInput
-
Note: the second dimension of the array
C
must be at least
.
On entry: the lower triangular Cholesky factorization
such that
gives the covariance matrix of the Wiener process. Elements of
C above the diagonal are not referenced.
- 9: LDC – INTEGERInput
On entry: the first dimension of the array
C as declared in the (sub)program from which G05XDF is called.
Constraint:
.
- 10: B(LDB,) – REAL (KIND=nag_wp) arrayOutput
-
Note: the second dimension of the array
B
must be at least
if
and at least
if
.
On exit: the scaled Wiener increments.
Let denote the th dimension of the th point of the th sample path where , and .
If , the increment will be stored at .
If , the increment will be stored at .
- 11: LDB – INTEGERInput
On entry: the first dimension of the array
B as declared in the (sub)program from which G05XDF is called.
Constraints:
- if , ;
- if , .
- 12: RCOMM() – REAL (KIND=nag_wp) arrayCommunication Array
-
On entry: communication array as returned by the last call to
G05XCF or G05XDF. This array
must not be directly modified.
- 13: IFAIL – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
-
On entry,
RCOMM was not initialized or has been corrupted.
On entry,
RCOMM was not initialized or has been corrupted.
On entry,
RCOMM was not initialized or has been corrupted.
-
On entry, .
Constraint: .
-
On entry, the value of
RCORD is invalid.
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, and .
Constraint: .
On entry, and .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, and .
Constraint: .
On entry, and .
Constraint: .
-
Dynamic memory allocation failed.
7 Accuracy
Not applicable.
None.
9 Example
The scaled Wiener increments produced by this routine 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 G05XDF 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.
9.1 Program Text
Program Text (g05xdfe.f90)
9.2 Program Data
None.
9.3 Program Results
Program Results (g05xdfe.r)