nag_rand_bb_make_bridge_order (g05xec) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_rand_bb_make_bridge_order (g05xec)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_rand_bb_make_bridge_order (g05xec) takes a set of input times and permutes them to specify one of several predefined Brownian bridge construction orders. The permuted times can be passed to nag_rand_bb_init (g05xac) or nag_rand_bb_inc_init (g05xcc) to initialize the Brownian bridge generators with the chosen bridge construction order.

2  Specification

#include <nag.h>
#include <nagg05.h>
void  nag_rand_bb_make_bridge_order (Nag_BridgeOrder bgord, double t0, double tend, Integer ntimes, const double intime[], Integer nmove, const Integer move[], double times[], NagError *fail)

3  Description

The Brownian bridge algorithm (see Glasserman (2004)) is a popular method for constructing a Wiener process at a set of discrete times, t0 < t1 < t2 < ,, < tN < T , for N1. To ease notation we assume that T has the index N+1 so that T=tN+1. Inherent in the algorithm is the notion of a bridge construction order which specifies the order in which the N+2 points of the Wiener process, Xt0,XT and Xti, for i=1,2,,N, are generated. The value of Xt0 is always assumed known, and the first point to be generated is always the final time XT. Thereafter, successive points are generated iteratively by an interpolation formula, using points which were computed at previous iterations. In many cases the bridge construction order is not important, since any construction order will yield a correct process. However, in certain cases, for example when using quasi-random variates to construct the sample paths, the bridge construction order can be important.

3.1  Supported Bridge Construction Orders

nag_rand_bb_make_bridge_order (g05xec) accepts as input an array of time points t1 , t2 ,, tN , T  at which the Wiener process is to be sampled. These time points are then permuted to construct the bridge. In all of the supported construction orders the first construction point is T which has index N+1. The remaining points are constructed by iteratively bisecting (sub-intervals of) the time indices interval 0,N+1 , as Figure 1 illustrates:
0 N+1 L 0 0 L 0 0 / 2 L 1 1 L 1 1 / 2 L 2 1 L 2 1 / 2 L 2 1 L 1 1 / 2 + ( ) L 2 1 - L 3 2 L 2 2 L 2 2 L 0 0 / 2 + ( ) L 2 2 - L 3 4 L 1 1 L 0 0 / 2 + ( ) L 1 1 - L 1 1 L 2 2 / 2 + ( ) L 1 1 - L 3 1 L 3 3
Figure 1
The time indices interval is processed in levels Li, for i=1,2,. Each level Li contains ni points L1i,,Lnii where ni2i-1. The number of points at each level depends on the value of N. The points Lji for i1 and j=1,2,ni are computed as follows: define L00=N+1 and set
Lji = J+ K-J/2 where J= max Lkp : 1knp , ​ 0p<i ​ and ​ Lkp < Lji ​ and ​ K = min Lkp : 1knp , ​ 0p<i ​ and ​ Lkp > Lji  
By convention the maximum of the empty set is taken to be to be zero. Figure 1 illustrates the algorithm when N+1 is a power of two. When N+1 is not a power of two, one must decide how to round the divisions by 2. For example, if one rounds down to the nearest integer, then one could get the following:
L 0 0 L 0 0 / 2 L 1 1 L 1 1 / 2 L 2 1 L 2 1 L 1 1 / 2 + ( ) L 2 1 - L 3 2 L 2 2 L 2 2 L 0 0 / 2 + ( ) L 2 2 - L 1 1 L 0 0 / 2 + ( ) L 1 1 - L 1 1 L 2 2 / 2 + ( ) L 1 1 - L 3 1 L 3 3 0 N+1
Figure 2
From the series of bisections outlined above, two ways of ordering the time indices Lji are supported. In both cases, levels are always processed from coarsest to finest (i.e., increasing i). Within a level, the time indices can either be processed left to right (i.e., increasing j) or right to left (i.e., decreasing j). For example, when processing left to right, the sequence of time indices could be generated as:
N+1 L11 L12 L22 L13 L23 L33 L43  
while when processing right to left, the same sequence would be generated as:
N+1 L11 L22 L12 L43 L33 L23 L13  
nag_rand_bb_make_bridge_order (g05xec) therefore offers four bridge construction methods; processing either left to right or right to left, with rounding either up or down. Which method is used is controlled by the bgord argument. For example, on the set of times
t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 T  
the Brownian bridge would be constructed in the following orders:
bgord=Nag_LRRoundDown (processing left to right, rounding down)
T t6 t3 t9 t1 t4 t7 t11 t2 t5 t8 t10 t12  
bgord=Nag_LRRoundUp (processing left to right, rounding up)
T t7 t4 t10 t2 t6 t9 t12 t1 t3 t5 t8 t11  
bgord=Nag_RLRoundDown (processing right to left, rounding down)
T t6 t9 t3 t11 t7 t4 t1 t12 t10 t8 t5 t2  
bgord=Nag_RLRoundUp (processing right to left, rounding up)
T t7 t10 t4 t12 t9 t6 t2 t11 t8 t5 t3 t1 .  
The four construction methods described above can be further modified through the use of the input array move. To see the effect of this argument, suppose that an array A holds the output of nag_rand_bb_make_bridge_order (g05xec) when nmove=0 (i.e., the bridge construction order as specified by bgord only). Let
B = tj : j=move[i-1], i=1,2,,nmove  
be the array of all times identified by move, and let C be the array A with all the elements in B removed, i.e.,
C = Ai : Ai Bj , i=1,2,,ntimes , j=1,2,,nmove .  
Then the output of nag_rand_bb_make_bridge_order (g05xec) when nmove>0 is given by
B1 B2 Bnmove C1 C2 Cntimes-nmove  
When the Brownian bridge is used with quasi-random variates, this functionality can be used to allow specific sections of the bridge to be constructed using the lowest dimensions of the quasi-random points.

4  References

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

5  Arguments

1:     bgord Nag_BridgeOrderInput
On entry: the bridge construction order to use.
Constraint: bgord=Nag_LRRoundDown, Nag_LRRoundUp, Nag_RLRoundDown or Nag_RLRoundUp.
2:     t0 doubleInput
On entry: t0, the start value of the time interval on which the Wiener process is to be constructed.
3:     tend doubleInput
On entry: T, the largest time at which the Wiener process is to be constructed.
4:     ntimes IntegerInput
On entry: N, the number of time points in the Wiener process, excluding t0 and T.
Constraint: ntimes1.
5:     intime[ntimes] const doubleInput
On entry: the time points, t1,t2,,tN, at which the Wiener process is to be constructed. Note that the final time T is not included in this array.
Constraints:
  • t0<intime[i-1] and intime[i-1]<intime[i], for i=1,2,,ntimes-1;
  • intime[ntimes-1]<tend.
6:     nmove IntegerInput
On entry: the number of elements in the array move.
Constraint: 0nmoventimes.
7:     move[nmove] const IntegerInput
On entry: the indices of the entries in intime which should be moved to the front of the times array, with move[j-1]=i setting the jth element of times to ti. Note that i ranges from 1 to ntimes. When nmove=0, move is not referenced and may be NULL.
Constraint: 1move[j-1]ntimes, for j=1,2,,nmove.
The elements of move must be unique.
8:     times[ntimes] doubleOutput
On exit: the output bridge construction order. This should be passed to nag_rand_bb_init (g05xac) or nag_rand_bb_inc_init (g05xcc).
9:     fail NagError *Input/Output
The NAG error argument (see Section 2.7 in How to Use the NAG Library and its Documentation).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, nmove=value and ntimes=value.
Constraint: 0nmoventimes.
On entry, ntimes=value.
Constraint: ntimes1.
NE_INT_ARRAY
On entry, move[value]=value.
Constraint: move[i]1 for all i.
On entry, move[value]=value and ntimes=value.
Constraint: move[i]ntimes for all i.
On entry, move[value] and move[value] both equal value.
Constraint: all elements in move must be unique.
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.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_NOT_STRICTLY_INCREASING
On entry, intime[value]=value and intime[value]=value.
Constraint: the elements in intime must be in increasing order.
NE_REAL_2
On entry, intime[0]=value and t0=value.
Constraint: intime[0]>t0.
On entry, ntimes=value, intime[ntimes-1]=value and tend=value.
Constraint: intime[ntimes-1]<tend.

7  Accuracy

Not applicable.

8  Parallelism and Performance

nag_rand_bb_make_bridge_order (g05xec) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
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.

9  Further Comments

None.

10  Example

This example calls nag_rand_bb_make_bridge_order (g05xec), nag_rand_bb_init (g05xac) and nag_rand_bb (g05xbc) to generate two sample paths of a three-dimensional free Wiener process. The array move is used to ensure that a certain part of the sample path is always constructed using the lowest dimensions of the input quasi-random points. For further details on using quasi-random points with the Brownian bridge algorithm, please see Section 2.6 in the g05 Chapter Introduction.

10.1  Program Text

Program Text (g05xece.c)

10.2  Program Data

None.

10.3  Program Results

Program Results (g05xece.r)


nag_rand_bb_make_bridge_order (g05xec) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG Library Manual

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