G05XCF (PDF version)
G05 Chapter Contents
G05 Chapter Introduction
NAG Library Manual

NAG Library Routine Document


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
    7  Accuracy

1  Purpose

G05XCF initializes the Brownian bridge increments generator G05XDF. It must be called before any calls to G05XDF.

2  Specification


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 t0<T and let ti 1iN  be any set of time points satisfying t0<t1<t2<⋯<tN<T. Let Xti 1iN  denote a d-dimensional Wiener sample path at these time points, and let C be any d by d matrix such that CCT is the desired covariance structure for the Wiener process. Each point Xti 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 Xt0 = xd . If we set XT =x+ C T-t0 Z  where Z is any d-dimensional standard Normal random variable, then X will behave like a normal (free) Wiener process. However if we fix the terminal value XT = wd , then X 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 X, and then uses this to compute the scaled Wiener increments
Xt1 - Xt0 t1 - t0 , Xt2 - Xt1 t2 - t1 ,, XtN - XtN-1 tN - tN-1 , XT - XtN T - tN .  
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 tj 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 P Wiener sample paths each of dimension d. The main input to the Brownian bridge increments generator is then an array of quasi-random points Z1,Z2,…,ZP where each point Zp = Z1p,Z2p,,ZDp  has dimension D=dN+1 or D=dN depending on whether a free or non-free Wiener process is required. When G05XDF is called, the pth sample path for 1pP is constructed as follows: if a non-free Wiener process is required set XT equal to the terminal value w, otherwise construct XT as
XT = Xt0 + C T-t0 Z1p Zdp  
where C is the matrix described in Section 3.1. The array TIMES holds the remaining time points t1 , t2 ,… tN  in the order in which the bridge is to be constructed. For each j=1,…,N set r=TIMESj, find
q = max t0, TIMESi : 1i<j , TIMESi < r  
s = min T, TIMESi : 1i<j , TIMESi > r  
and construct the point Xr as
Xr = Xq s-r + Xs r-q s-q + C s-r r-q s-q Zjd-ad+1p Zjd-ad+dp  
where a=0 or a=1 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
Xt1 - Xt0 t1 - t0 , Xt2 - Xt1 t2 - t1 ,…, XtN - XtN-1 tN - tN-1 , XT - XtN T - tN  
are computed.

4  References

Glasserman P (2004) Monte Carlo Methods in Financial Engineering Springer

5  Parameters

1:     T0 – REAL (KIND=nag_wp)Input
On entry: the starting value t0 of the time interval.
2:     TEND – REAL (KIND=nag_wp)Input
On entry: the end value T of the time interval.
Constraint: TEND>T0.
3:     TIMESNTIMES – REAL (KIND=nag_wp) arrayInput
On entry: the points in the time interval t0,T 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.
  • T0<TIMESi<TEND, for i=1,2,,NTIMES;
  • TIMESi TIMESj, for i,j=1,2,NTIMES and ij.
4:     NTIMES – INTEGERInput
On entry: the length of TIMES, denoted by N in Section 3.1.
Constraint: NTIMES1.
5:     RCOMM12×NTIMES+1 – 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:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. 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 -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
On entry, TEND=value and T0=value.
Constraint: TEND>T0.
On entry, NTIMES=value.
Constraint: NTIMES1.
On entry, TIMESvalue=value, T0=value and TEND=value.
Constraint: T0<TIMESi<TEND for all i.
On entry, TIMESi=TIMESj=value, for i=value and j=value.
Constraint: all elements of TIMES must be unique.
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

Not applicable.

8  Parallelism and Performance

Not applicable.

9  Further Comments

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 N 4  or even N 2 , which could be very inefficient when N 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


10.3  Program Results

Program Results (g05xcfe.r)

G05XCF (PDF version)
G05 Chapter Contents
G05 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2015