NAG Library Routine Document
g05xcf (bb_inc_init)
1
Purpose
g05xcf initializes the Brownian bridge increments generator
g05xdf. It must be called before any calls to
g05xdf.
2
Specification
Fortran Interface
Integer, Intent (In) | :: | ntimes | Integer, Intent (Inout) | :: | ifail | Real (Kind=nag_wp), Intent (In) | :: | t0, tend, times(ntimes) | Real (Kind=nag_wp), Intent (Out) | :: | rcomm(12*(ntimes+1)) |
|
3
Description
3.1
Brownian Bridge Algorithm
Details on the Brownian bridge algorithm and the Brownian bridge process (sometimes also called a non-free Wiener process) can be found in
Section 2.6 in the G05 Chapter Introduction. We briefly recall some notation and definitions.
Fix two times
and let
be any set of time points satisfying
. Let
denote a
-dimensional Wiener sample path at these time points, and let
be any
by
matrix such that
is the desired covariance structure for the Wiener process. Each point
of the sample path is constructed according to the Brownian bridge interpolation algorithm (see
Glasserman (2004) or
Section 2.6 in the G05 Chapter Introduction). We always start at some fixed point
. If we set
where
is any
-dimensional standard Normal random variable, then
will behave like a normal (free) Wiener process. However if we fix the terminal value
, then
will behave like a non-free Wiener process.
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
Such increments can be useful in computing numerical solutions to stochastic differential equations driven by (free or non-free) Wiener processes.
3.2
Implementation
Conceptually, the output of the Wiener increments generator is the same as if
g05xaf and
g05xbf were called first, and the scaled increments then constructed from their output. The implementation adopts a much more efficient approach whereby the scaled increments are computed directly without first constructing the Wiener sample path.
Given the start and end points of the process, the order in which successive interpolation times
are chosen is called the
bridge construction order. The construction order is given by the array
times. Further information on construction orders is given in
Section 2.6.2 in the G05 Chapter Introduction. For clarity we consider here the common scenario where the Brownian bridge algorithm is used with quasi-random points. If pseudorandom numbers are used instead, these details can be ignored.
Suppose we require the increments of
Wiener sample paths each of dimension
. The main input to the Brownian bridge increments generator is then an array of quasi-random points
where each point
has dimension
or
depending on whether a free or non-free Wiener process is required. When
g05xdf is called, the
th sample path for
is constructed as follows: if a non-free Wiener process is required set
equal to the terminal value
, otherwise construct
as
where
is the matrix described in
Section 3.1. The array
times holds the remaining time points
in the order in which the bridge is to be constructed. For each
set
, find
and
and construct the point
as
where
or
depending on whether a free or non-free Wiener process is required. The routine
g05xef can be used to initialize the
times array for several predefined bridge construction orders. Lastly, the scaled Wiener increments
are computed.
4
References
Glasserman P (2004) Monte Carlo Methods in Financial Engineering Springer
5
Arguments
- 1: – Real (Kind=nag_wp)Input
-
On entry: the starting value of the time interval.
- 2: – Real (Kind=nag_wp)Input
-
On entry: the end value of the time interval.
Constraint:
.
- 3: – Real (Kind=nag_wp) arrayInput
-
On entry: the points in the time interval
at which the Wiener process is to be constructed. The order in which points are listed in
times determines the bridge construction order. The routine
g05xef can be used to create predefined bridge construction orders from a set of input times.
Constraints:
- , for ;
- , for and .
- 4: – IntegerInput
-
On entry: the length of
times, denoted by
in
Section 3.1.
Constraint:
.
- 5: – Real (Kind=nag_wp) arrayCommunication Array
-
On exit: communication array, used to store information between calls to
g05xdf. This array
must not be directly modified.
- 6: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, 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, and .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, , and .
Constraint: for all .
-
On entry,
, for
and
.
Constraint: all elements of
times must be unique.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
Not applicable.
8
Parallelism and Performance
g05xcf is not threaded in any implementation.
The efficient implementation of a Brownian bridge algorithm requires the use of a workspace array called the
working stack. Since previously computed points will be used to interpolate new points, they should be kept close to the hardware processing units so that the data can be accessed quickly. Ideally the whole stack should be held in hardware cache. Different bridge construction orders may require different amounts of working stack. Indeed, a naive bridge algorithm may require a stack of size
or even
, which could be very inefficient when
is large.
g05xcf performs a detailed analysis of the bridge construction order specified by
times. Heuristics are used to find an execution strategy which requires a small working stack, while still constructing the bridge in the order required.
10
Example
The following example program calls
g05xaf and
g05xbf to generate two sample paths from a two-dimensional free Wiener process. It then calls
g05xcf and
g05xdf with the same input arguments to obtain the scaled increments of the Wiener sample paths. Lastly, the program prints the Wiener sample paths from
g05xbf, the scaled increments from
g05xdf, and the cumulative sum of the unscaled increments side by side. Note that the cumulative sum of the unscaled increments is identical to the output of
g05xbf.
Please see
Section 10 in
g05xdf for additional examples.
10.1
Program Text
Program Text (g05xcfe.f90)
10.2
Program Data
None.
10.3
Program Results
Program Results (g05xcfe.r)