# naginterfaces.library.rand.bb_​make_​bridge_​order¶

naginterfaces.library.rand.bb_make_bridge_order(t0, tend, intime, bgord=1, move=None)[source]

bb_make_bridge_order 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 bb_init() or bb_inc_init() to initialize the Brownian bridge generators with the chosen bridge construction order.

For full information please refer to the NAG Library document for g05xe

https://www.nag.com/numeric/nl/nagdoc_27.1/flhtml/g05/g05xef.html

Parameters
t0float

, the start value of the time interval on which the Wiener process is to be constructed.

tendfloat

, the largest time at which the Wiener process is to be constructed.

intimefloat, array-like, shape

The time points, , at which the Wiener process is to be constructed. Note that the final time is not included in this array.

bgordint, optional

The bridge construction order to use.

moveNone or int, array-like, shape , optional

The indices of the entries in which should be moved to the front of the array, with setting the th element of to . Note that ranges from to . When , is not referenced.

Returns
timesfloat, ndarray, shape

The output bridge construction order. This should be passed to bb_init() or bb_inc_init().

Raises
NagValueError
(errno )

An unexpected error occurred during execution of bb_make_bridge_order. Please contact NAG with the following error message: error in , .

(errno )

On entry, .

Constraint: , , or

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: the elements in must be in increasing order.

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, .

Constraint: for all .

(errno )

On entry, and .

Constraint: for all .

(errno )

On entry, and both equal .

Constraint: all elements in must be unique.

Notes

The Brownian bridge algorithm (see Glasserman (2004)) is a popular method for constructing a Wiener process at a set of discrete times, , for . To ease notation we assume that has the index so that . Inherent in the algorithm is the notion of a bridge construction order which specifies the order in which the points of the Wiener process, and , for , are generated. The value of is always assumed known, and the first point to be generated is always the final time . 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.

Supported Bridge Construction Orders

bb_make_bridge_order accepts as input an array of time points 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 which has index . The remaining points are constructed by iteratively bisecting (sub-intervals of) the time indices interval , as Figure [label omitted] illustrates:

[figure omitted]

The time indices interval is processed in levels , for . Each level contains points where . The number of points at each level depends on the value of . The points for and are computed as follows: define and set

By convention the maximum of the empty set is taken to be to be zero. Figure [label omitted] illustrates the algorithm when is a power of two. When is not a power of two, one must decide how to round the divisions by . For example, if one rounds down to the nearest integer, then one could get the following:

[figure omitted]

From the series of bisections outlined above, two ways of ordering the time indices are supported. In both cases, levels are always processed from coarsest to finest (i.e., increasing ). Within a level, the time indices can either be processed left to right (i.e., increasing ) or right to left (i.e., decreasing ). For example, when processing left to right, the sequence of time indices could be generated as:

while when processing right to left, the same sequence would be generated as:

bb_make_bridge_order, 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 argument. For example, on the set of times

the Brownian bridge would be constructed in the following orders:

(processing left to right, rounding down)

(processing left to right, rounding up)

(processing right to left, rounding down)

(processing right to left, rounding up)

The four construction methods described above can be further modified through the use of the input array . To see the effect of this argument, suppose that an array holds the output of bb_make_bridge_order when (i.e., the bridge construction order as specified by only). Let

be the array of all times identified by , and let be the array with all the elements in removed, i.e.,

Then the output of bb_make_bridge_order when is given by

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.

References

Glasserman, P, 2004, Monte Carlo Methods in Financial Engineering, Springer