naginterfaces.library.rand.bb

naginterfaces.library.rand.bb(npaths, start, term, z, c, comm, rcord=2, a=1)[source]

bb uses a Brownian bridge algorithm to construct sample paths for a free or non-free Wiener process. The initialization function bb_init() must be called prior to the first call to bb.

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

https://support.nag.com/numeric/nl/nagdoc_30.1/flhtml/g05/g05xbf.html

Parameters
npathsint

The number of Wiener sample paths to create.

startfloat, array-like, shape

The starting value of the Wiener process.

termfloat, array-like, shape

The terminal value at which the non-free Wiener process should end. If , is ignored.

zfloat, array-like, shape

Note: the required extent for this argument in dimension 1 is determined as follows: if : ; if : ; otherwise: .

Note: the required extent for this argument in dimension 2 is determined as follows: if : ; if : ; otherwise: .

The Normal random numbers used to construct the sample paths.

If quasi-random numbers are used, the -dimensional quasi-random points should be stored in successive rows of .

cfloat, array-like, shape

The lower triangular Cholesky factorization such that gives the covariance matrix of the Wiener process. Elements of above the diagonal are not referenced.

commdict, communication object

Communication structure.

This argument must have been initialized by a prior call to bb_init().

rcordint, optional

The order in which Normal random numbers are stored in and in which the generated values are returned in .

aint, optional

If , a free Wiener process is created beginning at and is ignored.

If , a non-free Wiener process is created beginning at and ending at .

Returns
zfloat, ndarray, shape

The Normal random numbers premultiplied by .

bfloat, ndarray, shape

The values of the Wiener sample paths.

Let denote the th dimension of the th point of the th sample path where , and .

The point is stored at .

The starting value is never stored, whereas the terminal value is always stored.

Raises
NagValueError
(errno )

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

(errno )

On entry, [‘rcomm’] was not initialized or has been corrupted.

(errno )

On entry, .

Constraint: .

(errno )

On entry, the value of is invalid.

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

Notes

For details on the Brownian bridge algorithm and the bridge construction order see the G05 Introduction and Notes for bb_init. 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.

References

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