PathPlot - Maple Help

Finance

 PathPlot
 plot sample path(s) of a stochastic process

 Calling Sequence PathPlot(samplepath, opts) PathPlot(samplepath, i, opts) PathPlot(expression, t = timeinterval, opts) PathPlot(pathgenerator, opts) PathPlot(process, timegrid, opts) PathPlot(process, timeinterval, opts) PathPlot(transform, pathgenerator, opts)

Parameters

 samplepath - Array; array containing sample path(s) of a stochastic process i - positive integer; coordinate of a multi-dimensional process to be plotted expression - algebraic expression; expression whose sample path is to be generated t - name; time variable for use in expression timeinterval - range; time interval pathgenerator - path generator data structure; path generator process - one- or multi- dimensional stochastic process, or list or vector of one-dimensional stochastic processes timegrid - list, Vector or time grid data structure; time grid transform - procedure; path function opts - (optional) equation(s) of the form option = value where option is one of timesteps, replications, color, markers, scale, or timegrid; specify options for the PathPlot command

Options

 • replications = posint -- This option specifies the number of replications of the sample path. By default, only one replication of the sample path is generated. This option is invalid when an array containing sample path data is passed explicitly.
 • timesteps = posint -- This option specifies the number of time steps. This option is ignored if explicit time grid is specified. By default, only one time step is used. This option is invalid when an array containing sample path data is passed explicitly.
 • color = name, list, or range -- This option specifies colors for the individual paths. If a list of colors is given, each of the lines will be colored with the corresponding color in the list. If a range of colors is given, the colors will be generated by selecting an appropriate number of equally-spaced points in the corresponding hue range.
 • markers = true or false -- This option specifies whether PathPlot plots the individual points.
 • scale = absolute or relative -- This option controls whether the absolute or relative data scale is used. If scale is set to relative, all data samples are rescaled so that their range is an interval between -1 and 1.
 • timegrid = range or a time grid data structure -- This option specifies the time grid to be used.

Description

 • The PathPlot command generates a line chart for the specified sample path(s).
 • The PathPlot(samplepath, opts) calling sequence plots data from samplepath as though it represents sample paths of a one-dimensional stochastic process. Each row of samplepath is taken as a single replication of the sample path.
 • The PathPlot(samplepath, i, opts) calling sequence plots data from samplepath as though it represents sample paths of a multi-dimensional stochastic process.
 • All the remaining calling sequences are closely related to the corresponding sequences for the SamplePath command. Essentially, they work as follows: the SamplePath command is called to generate an array containing sample paths for the underlying stochastic process. These sample paths are plotted using the procedure described above.
 • The PathPlot(expression, t = timeinterval, opts) calling sequence attempts to extract all the stochastic variables involved in expression and generate the corresponding path generator and path function using the time grid or the specified number of time steps. In this case, only a one-dimensional path can be generated. The parameter timeinterval must be of type range ${T}_{0}..{T}_{1}$, where ${T}_{0}$ and ${T}_{1}$ are non-negative constants such that ${T}_{0}<{T}_{1}$.
 Note that if $0<{T}_{0}$, the value at ${T}_{0}$ 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 ${T}_{0}$ and ${T}_{1}$, but will have no effect on the value at ${T}_{0}$. To reduce the bias, use a time interval of the form $0..{T}_{1}$. All stochastic variables involved in expression should be of the form $X\left(t\right)$. If $X$ is multi-dimensional stochastic, then the individual components of $X$ can be accessed using the notation ${X\left(t\right)}_{i}$.
 • The PathPlot(pathgenerator, opts) calling sequence plots the specified number of replications of the sample path using the path generator pathgenerator. For more details, see Finance[PathGenerator].
 • The PathPlot(transform, pathgenerator, opts) calling sequence plots sample paths for a certain one-dimensional stochastic process given a path generator pathgenerator and a procedure transform that converts paths generated by pathgenerator to paths of the stochastic process of interest. Note that pathgenerator can be multi-dimensional.
 • Note that the final plot data structure is built using the plots[display] command; all unprocessed parameters are treated as plot options and will be passed to plots[display].

Examples

 > $\mathrm{with}\left(\mathrm{Finance}\right):$
 > $W≔\mathrm{WienerProcess}\left(\right):$

Generate plots for a given data sample.

 > $A≔\mathrm{SamplePath}\left(W\left(t\right),t=0..3,\mathrm{timesteps}=100,\mathrm{replications}=10\right)$
 ${A}{≔}\begin{array}{c}\left[\begin{array}{ccccccccccc}{0.}& {-0.0830244583256831}& {0.0527984106640504}& {-0.0338884069474335}& {-0.118940917552953}& {-0.0777478384782254}& {-0.103423870584810}& {-0.115678600938565}& {0.0689293141024278}& {-0.182123155804597}& {\dots }\\ {0.}& {-0.203950613552794}& {-0.202536990221660}& {-0.433909032795154}& {-0.574319909036658}& {-0.524081395085286}& {-0.602038367301755}& {-0.516563291758918}& {-0.359353957477648}& {-0.799161754071190}& {\dots }\\ {0.}& {-0.0549230602346678}& {-0.329478695059128}& {-0.685339139780482}& {-0.584691817007243}& {-0.484845858580550}& {-0.552053414281415}& {-0.388030345815647}& {-0.361961006830835}& {-0.205523238582987}& {\dots }\\ {0.}& {-0.314166562531571}& {-0.146343665757784}& {-0.173092890694114}& {-0.250902323530825}& {-0.142514105099571}& {-0.0945320213169290}& {-0.0619995730120286}& {0.00585406295676987}& {0.126880879873725}& {\dots }\\ {0.}& {0.0525661285526199}& {-0.0357084829985467}& {-0.0278049590015776}& {-0.365441965504789}& {-0.112600849146251}& {-0.508576832151828}& {-0.709530592797295}& {-1.00200708772265}& {-0.603918361204094}& {\dots }\\ {0.}& {0.260182410863991}& {0.400917115301036}& {0.173363030648694}& {0.271582130761420}& {0.342689257589394}& {0.336995520930673}& {0.0988963769983819}& {0.106961148878815}& {0.0711135197050586}& {\dots }\\ {0.}& {-0.167110452143832}& {-0.388567536732902}& {-0.597995558199791}& {-0.431081238916942}& {-0.289447810115906}& {0.0435769555157546}& {0.333639951057388}& {0.445411297426723}& {0.301340388693111}& {\dots }\\ {0.}& {0.334258159417642}& {0.556515884375298}& {0.276328239902644}& {0.524623609579248}& {0.380848969319967}& {0.364987783391081}& {0.831672121873932}& {0.711004583270988}& {0.947991814717877}& {\dots }\\ {0.}& {0.0949225012085647}& {-0.226557675630234}& {-0.421218504333754}& {-0.273991639976306}& {-0.393549092120702}& {-0.293557322903973}& {-0.592321720101991}& {-0.772115291786765}& {-0.729811361377143}& {\dots }\\ {0.}& {-0.291084407126465}& {-0.446020245710355}& {-0.610480180355183}& {-0.530257835168335}& {-0.324218574561480}& {-0.360832989377286}& {-0.476275021195379}& {-0.363388630568751}& {-0.423699623521585}& {\dots }\end{array}\right]\\ \hfill {\text{10 × 101 Array}}\end{array}$ (1)
 > $\mathrm{PathPlot}\left(A,\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true},\mathrm{markers}=\mathrm{false},\mathrm{thickness}=3,\mathrm{color}=\mathrm{red}..\mathrm{blue}\right)$
 > $\mathrm{PathPlot}\left(A,\mathrm{timegrid}=0..1,\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true},\mathrm{markers}=\mathrm{false},\mathrm{thickness}=3,\mathrm{color}=\mathrm{red}..\mathrm{blue}\right)$
 > $T≔\mathrm{TimeGrid}\left(\left[\mathrm{seq}\left(1+\frac{i}{100},i=1..100\right)\right]\right)$
 ${T}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (2)
 > $\mathrm{PathPlot}\left(A,\mathrm{timegrid}=T,\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true}\right)$

Display sample plots for a given stochastic process.

 > $\mathrm{PathPlot}\left(W\left(t\right),t=0..3,\mathrm{timesteps}=100,\mathrm{replications}=10,\mathrm{axes}=\mathrm{boxed},\mathrm{thickness}=3,\mathrm{color}=\mathrm{red}..\mathrm{blue}\right)$
 > $\mathrm{PathPlot}\left(W\left(t\right),t=0..3,\mathrm{timesteps}=100,\mathrm{replications}=10,\mathrm{thickness}=3,\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true}\right)$

Generate sample paths for an expression involving stochastic variables.

 > $\mathrm{PathPlot}\left(\mathrm{exp}\left(W\left(t\right)\right),t=0..3,\mathrm{timesteps}=100,\mathrm{replications}=10,\mathrm{axes}=\mathrm{boxed},\mathrm{thickness}=3,\mathrm{color}=\mathrm{red}..\mathrm{blue}\right)$
 > $\mathrm{PathPlot}\left(\mathrm{exp}\left(W\left(t\right)\right),t=0..3,\mathrm{timesteps}=100,\mathrm{replications}=10,\mathrm{thickness}=3,\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true}\right)$

The commands to create the plot from the Plotting Guide are as follows. They show examples involving a multi-variate stochastic process.

 > $\mathrm{S0}≔700$
 ${\mathrm{S0}}{≔}{700}$ (3)
 > $\mathrm{V0}≔0.1$
 ${\mathrm{V0}}{≔}{0.1}$ (4)
 > $\mathrm{\kappa }≔1.0$
 ${\mathrm{\kappa }}{≔}{1.0}$ (5)
 > $\mathrm{\theta }≔0.1$
 ${\mathrm{\theta }}{≔}{0.1}$ (6)
 > $\mathrm{\mu }≔0.05$
 ${\mathrm{\mu }}{≔}{0.05}$ (7)
 > $\mathrm{\sigma }≔0.1$
 ${\mathrm{\sigma }}{≔}{0.1}$ (8)
 > $\mathrm{\rho }≔0.5$
 ${\mathrm{\rho }}{≔}{0.5}$ (9)
 > $S≔\mathrm{HestonProcess}\left(\mathrm{S0},\mathrm{V0},\mathrm{\mu },\mathrm{\theta },\mathrm{\kappa },\mathrm{\sigma },\mathrm{\rho }\right):$
 > $A≔\mathrm{SamplePath}\left(S\left(t\right),t=0..3,\mathrm{timesteps}=100,\mathrm{replications}=5\right)$
 ${A}{≔}\begin{array}{c}\left[\begin{array}{cc}{700.}& {647.693022731674}\\ {657.811765472812}& {621.110309468956}\\ {633.390649495592}& {661.894209764047}\\ {595.951908218144}& {628.876388831282}\\ {637.791181455956}& {635.955428009216}\end{array}\right]\\ \hfill {\text{slice of 5 × 2 × 101 Array}}\end{array}$ (10)

These are sample paths for the state variables.

 > $\mathrm{PathPlot}\left(A,\mathrm{timegrid}=0..3,1,\mathrm{thickness}=3,\mathrm{color}=\mathrm{red}..\mathrm{blue},\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true}\right)$

And these are the corresponding sample paths for the volatility.

 > $\mathrm{PathPlot}\left(A,\mathrm{timegrid}=0..3,2,\mathrm{thickness}=3,\mathrm{color}=\mathrm{red}..\mathrm{blue},\mathrm{axes}=\mathrm{boxed},\mathrm{gridlines}=\mathrm{true}\right)$

Compatibility

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