PathGenerator - Maple Help

Finance

 PathGenerator
 create new path generator for a stochastic process

 Calling Sequence PathGenerator(process, timegrid) PathGenerator(process, timeinterval, timesteps)

Parameters

 process - stochastic process; process for the path to be generated timegrid - list, Vector, or time grid; time grid timeinterval - range; length of simulation interval timesteps - positive integer; number of time steps

Description

 • The PathGenerator command creates a new path generator for the specified stochastic process. This command returns a module that can be used to simulate the underlying stochastic process as if it were a Maple procedure. Assume, for example, that the module returned by the PathGenerator command is assigned to the name $T$. Then for any positive integer $n$, $T\left(n\right)$ will return $n$ replications of the sample path of the underlying process.
 • In the one-dimensional case, the value returned by $T$ is a matrix of size $m×n$, where $m$ is the requested number of replications of the sample path (see the replications option) and $n$ is the number of points in the time grid (the number of time steps plus one). Each row of this matrix is a single realization of the sample path of the stochastic process of interest. In the multi-dimensional case, the value returned by $T$ is a matrix of size $m×d×n$, where $m$ and $n$ are the same as in the one-dimensional case, and $d$ is the dimension of the stochastic process to be simulated, which is either given explicitly or deduced from the dimension of the underlying stochastic process.
 • The module returned by the PathGenerator command can be passed to other commands such as Finance[SamplePath] or Finance[SampleValues] to simulate the underlying stochastic process.
 • The PathGenerator(process, timegrid) calling sequence creates a path generator for process based on the specified time grid.
 • The PathGenerator(process, timeinterval, timesteps) calling sequence constructs a path generator for process based on a uniform time grid on the interval timeinterval using the specified number of time steps. The parameter timeinterval must be of type range $\mathrm{t0}..\mathrm{t1}$, where $\mathrm{t0}$ and $\mathrm{t1}$ are non-negative real constants such that $\mathrm{t0}<\mathrm{t1}$. Note that if $0<\mathrm{t0}$, the value at $\mathrm{t0}$ will be simulated using a single step of the default discretization method and hence can suffer from a significant discretization bias. Increasing the number of time steps will refine the grid between $\mathrm{t0}$ and $\mathrm{t1}$, but will have no effect on the value at $\mathrm{t0}$. To reduce the bias, use a time interval of the form $0..\mathrm{t1}$.

Examples

 > $\mathrm{with}\left(\mathrm{Finance}\right):$
 > $\mathrm{W1}≔\mathrm{WienerProcess}\left(\right):$
 > $\mathrm{P1}≔\mathrm{PathGenerator}\left(\mathrm{W1},0..3\right):$
 > $\mathrm{P1}\left(5\right)$
 $\left[\begin{array}{cc}{0.}& {-0.830244583256831}\\ {0.}& {1.35822868989733}\\ {0.}& {-0.866868176114839}\\ {0.}& {-0.850525106055196}\\ {0.}& {0.411930790747278}\end{array}\right]$ (1)
 > $\mathrm{P2}≔\mathrm{PathGenerator}\left(\mathrm{W1},0..3,10\right)$
 ${\mathrm{P2}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{option}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{implementation}}{=}{"External/0x7f96a6933e00"}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{export}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{process}}{,}{\mathrm{timegrid}}{,}{\mathrm{ModuleApply}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (2)
 > $\mathrm{P2}\left(5\right)$
 $\begin{array}{c}\left[\begin{array}{ccccccccccc}{0.}& {-0.0811947427324198}& {-0.119947602761486}& {0.463833882862908}& {-0.330063734254170}& {-0.0168871289670550}& {0.126379736928991}& {-0.306758334181076}& {0.322854864001681}& {0.479787764815203}& {\dots }\\ {0.}& {-0.00492898979863218}& {-0.121838711002455}& {-0.131371645086013}& {-0.180341765552680}& {-0.289462894765095}& {0.0159547400046156}& {-0.178266328972839}& {-0.239832577976563}& {-0.261088358560076}& {\dots }\\ {0.}& {0.147433495337267}& {0.539504032806130}& {0.257921359255396}& {-0.0250918401977724}& {0.319256097355939}& {0.682647807874565}& {0.691160892192652}& {1.14336176696318}& {1.32752331972683}& {\dots }\\ {0.}& {-0.182959136690252}& {-0.497317926585168}& {-0.745287570105459}& {-0.827204217971913}& {-1.69169264270178}& {-2.13784833308387}& {-2.57420907662394}& {-2.51010649952294}& {-1.90245207288317}& {\dots }\\ {0.}& {0.274651245853641}& {0.172859336562135}& {-0.135222721605727}& {-0.588083204065737}& {-0.0900635741403155}& {-0.632650612000361}& {-1.24513291817451}& {-2.15247764663225}& {-0.771019009379988}& {\dots }\end{array}\right]\\ \hfill {\text{5 × 11 Array}}\end{array}$ (3)

Here is a path generator based on a non-homogeneous grid.

 > $G≔⟨0,0.3,0.5,0.7,1.0,\mathrm{seq}\left(1.+\frac{i}{10},i=1..10\right)⟩$
 ${G}{≔}\begin{array}{c}\left[\begin{array}{c}{0}\\ {0.3}\\ {0.5}\\ {0.7}\\ {1.0}\\ {1.100000000}\\ {1.200000000}\\ {1.300000000}\\ {1.400000000}\\ {1.500000000}\\ {⋮}\end{array}\right]\\ \hfill {\text{15 element Vector[column]}}\end{array}$ (4)
 > $\mathrm{P3}≔\mathrm{PathGenerator}\left(\mathrm{W1},G\right)$
 ${\mathrm{P3}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{option}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{implementation}}{=}{"External/0x7f96a63b42d8"}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{export}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{process}}{,}{\mathrm{timegrid}}{,}{\mathrm{ModuleApply}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (5)
 > $\mathrm{PathPlot}\left(\mathrm{P3}\left(20\right),\mathrm{thickness}=2,\mathrm{axes}=\mathrm{BOXED}\right)$

This is simulating a multi-dimensional process.

 > $\mathrm{W2}≔\mathrm{WienerProcess}\left(⟨⟨1.0,0.5⟩|⟨0.5,1.0⟩⟩\right)$
 ${\mathrm{W2}}{≔}{\mathrm{_W0}}$ (6)
 > $\mathrm{P4}≔\mathrm{PathGenerator}\left(\mathrm{W2},0..3,3\right)$
 ${\mathrm{P4}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{option}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{implementation}}{=}{"External/0x7f96a77da818"}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{export}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{process}}{,}{\mathrm{timegrid}}{,}{\mathrm{ModuleApply}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (7)
 > $\mathrm{P4}\left(5\right)$
 $\begin{array}{c}\left[\begin{array}{cc}{0.}& {-0.295434097645586}\\ {0.419457045795490}& {0.109544576788637}\\ {0.259741036855753}& {0.623176175699569}\\ {0.319071361855492}& {0.}\\ {0.}& {-0.845976963353925}\end{array}\right]\\ \hfill {\text{slice of 5 × 2 × 4 Array}}\end{array}$ (8)

This is creating a path generator for a Vector of one-dimensional processes.

 > $\mathrm{W3}≔\mathrm{PoissonProcess}\left(0.5\right):$
 > $\mathrm{P5}≔\mathrm{PathGenerator}\left(\left[\mathrm{W1},\mathrm{W3}\right],0..3,20\right)$
 ${\mathrm{P5}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{option}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{implementation}}{=}{"External/0x7f96a7872000"}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{export}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{process}}{,}{\mathrm{timegrid}}{,}{\mathrm{ModuleApply}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (9)
 > $\mathrm{P5}\left(1\right)$
 $\begin{array}{c}\left[\begin{array}{cc}{0.}& {-0.181461874482944}\end{array}\right]\\ \hfill {\text{slice of 1 × 2 × 21 Array}}\end{array}$ (10)

Compatibility

 • The Finance[PathGenerator] command was introduced in Maple 15.