 BrownianMotion - Maple Help

Home : Support : Online Help : Mathematics : Finance : Stochastic Processes : Finance/BrownianMotion

Finance

 BrownianMotion
 define one- or multi-dimensional Brownian motion process Calling Sequence BrownianMotion(${x}_{0}$, mu, sigma, opts) BrownianMotion(${x}_{0}$, mu, sigma, t, opts) BrownianMotion(${X}_{0}$, Mu, Sigma) Parameters

 ${x}_{0}$ - real constant; initial value mu - algebraic expression, operator or procedure; drift parameter sigma - algebraic expression, operator, procedure or a one-dimensional stochastic process; volatility t - time parameter ${X}_{0}$ - Vector; initial value Mu - Vector; drift parameter Sigma - Matrix; covariance matrix opts - (optional) equation(s) of the form option = value where option is scheme; specify options for the BrownianMotion command Options

 • scheme = unbiased or Euler -- This option specifies which discretization scheme should be used for simulating this process. Description

 • The BrownianMotion(${x}_{0}$, mu, sigma) and BrownianMotion(${x}_{0}$, mu, sigma, t) commands create a new one-dimensional Brownian motion process. This is a stochastic process $X\left(t\right)$, which is governed by the stochastic differential equation (SDE)

$\mathrm{dX}\left(t\right)=\mathrm{\mu }\left(t\right)\mathrm{dt}+\mathrm{\sigma }\left(t\right)\mathrm{dW}\left(t\right)$

where

 – $\mathrm{\mu }=\mathrm{\mu }\left(t\right)$ is the drift,
 – $\mathrm{\sigma }=\mathrm{\sigma }\left(t\right)$ is the volatility,

and

 – $W\left(t\right)$ is the standard Wiener process.
 • The parameter ${x}_{0}$ defines the initial value of the underlying stochastic process. It must be a real constant.
 • In the simplest case of a constant drift, mu is a real number (i.e. any expression of type $\mathrm{realcons}$). Time-dependent drift can be given either as an algebraic expression or as a Maple procedure. If mu is given as an algebraic expression, then the parameter $t$ must be passed to specify which variable in mu should be used as a time variable. Maple procedure defining a time-dependent drift must accept one parameter (the time) and return the corresponding value for the drift.
 • Similar to the drift, the volatility parameter can be constant or time dependent. In addition to this, the volatility can involve other (one-dimensional) stochastic variables. Note that stochastic drift is not supported.
 • The BrownianMotion(${X}_{0}$, Mu, Sigma) defines an $n$-dimensional Brownian motion with drift Mu and covariance Sigma. This process is defined by the SDE

$\mathrm{dX}\left(t\right)=\mathrm{Μ}\mathrm{dt}+B\mathrm{dW}\left(t\right)$

where

 – $\mathrm{Μ}$ is a vector of size $n$,
 – $B$ is a $n×m$-matrix $B{B}^{T}=\mathrm{\Sigma }$,

and

 – $W\left(t\right)$ is the standard $m$-dimensional Wiener process.
 • In this case the drift vector and the covariance matrix are time-independent. The drift parameter Mu must be given as a Vector and the covariance matrix Sigma must be a given as a symmetric matrix (see Matrix).
 • The scheme option specifies the discretization scheme used for simulation of this process. By default the standard Euler scheme is used. When scheme is set to unbiased the transition density will be used to simulate a value $X\left(t+\mathrm{dt}\right)$ given $X\left(t\right)$. This scheme is appropriate in the case of a time-dependent drift and/or volatility. Examples

 > $\mathrm{with}\left(\mathrm{Finance}\right):$
 > $T≔2.0$
 ${T}{≔}{2.0}$ (1)

First consider the case of a one-dimensional Brownian motion with constant drift and volatility.

 > $X≔\mathrm{BrownianMotion}\left(0.,0.02,0.3\right):$
 > $A≔\mathrm{SamplePath}\left(X\left(t\right),t=0..T,\mathrm{timesteps}=100,\mathrm{replications}=10\right)$
 ${A}{≔}\begin{array}{c}\left[\begin{array}{ccccccccccc}{0.}& {-0.0199367559068890}& {0.0137329165356845}& {-0.00710093052170006}& {-0.0275344557543178}& {-0.0170442532875976}& {-0.0229335710156428}& {-0.0255353546458524}& {0.0200841647870977}& {-0.0410108802066662}& {\dots }\\ {0.}& {-0.0495574935931906}& {-0.0488112280082134}& {-0.105085572513270}& {-0.139079072626146}& {-0.126373200164491}& {-0.145068680546758}& {-0.123731648466178}& {-0.0848233832870040}& {-0.192153851942199}& {\dots }\\ {0.}& {-0.0130533472687082}& {-0.0799054684012920}& {-0.166673119322014}& {-0.141619660844850}& {-0.116762495742396}& {-0.132824917575076}& {-0.0922476351964036}& {-0.0854619773519601}& {-0.0467427064812606}& {\dots }\\ {0.}& {-0.0765547772446533}& {-0.0350467308194981}& {-0.0411989260303922}& {-0.0598582667929221}& {-0.0329086838643322}& {-0.0207555216580378}& {-0.0123867318149901}& {0.00463394671662148}& {0.0346793413805995}& {\dots }\\ {0.}& {0.0132760192707464}& {-0.00794675628352876}& {-0.00561079618728711}& {-0.0879146346086505}& {-0.0255814625012419}& {-0.122175373377306}& {-0.170998790924784}& {-0.242240608357267}& {-0.144329183124786}& {\dots }\\ {0.}& {0.0641314146663945}& {0.0990042361636108}& {0.0436650965351782}& {0.0681237643623298}& {0.0859413821427202}& {0.0849467071883558}& {0.0270245661055954}& {0.0294000237054962}& {0.0210191837090750}& {\dots }\\ {0.}& {-0.0405335338438174}& {-0.0943792195605768}& {-0.145278398604029}& {-0.103992907303331}& {-0.0688999441949964}& {0.0130741305557560}& {0.0845247637897755}& {0.112303040436651}& {0.0774130191190072}& {\dots }\\ {0.}& {0.0822761932935098}& {0.137117995047320}& {0.0688863189282857}& {0.130106015048625}& {0.0952885643898804}& {0.0918033831657622}& {0.206517233188892}& {0.177359843379411}& {0.235809622639385}& {\dots }\\ {0.}& {0.0236511693069703}& {-0.0546950702605056}& {-0.101977040583600}& {-0.0655139711730303}& {-0.0943994464431291}& {-0.0695065651372171}& {-0.142288597781752}& {-0.185928848747772}& {-0.175166544385994}& {\dots }\\ {0.}& {-0.0709008269540398}& {-0.108452201694115}& {-0.148336493995245}& {-0.128286112827525}& {-0.0774170072808127}& {-0.0859856706337453}& {-0.113863077916192}& {-0.0858116723222182}& {-0.100184788183722}& {\dots }\end{array}\right]\\ \hfill {\text{10 × 101 Array}}\end{array}$ (2)
 > $\mathrm{PathPlot}\left(X\left(t\right),t=0..T,\mathrm{timesteps}=100,\mathrm{replications}=10,\mathrm{axes}=\mathrm{BOXED},\mathrm{gridlines}=\mathrm{true}\right)$ Compute the drift and diffusion for functions of $X$.

 > $W≔\mathrm{BrownianMotion}\left(1,\mathrm{\mu }\left(t\right),\mathrm{\sigma }\left(t\right),t\right)$
 ${W}{≔}{\mathrm{_X1}}$ (3)
 > $\mathrm{Drift}\left(W\left(u\right)\right)$
 ${\mathrm{\mu }}{}\left({u}\right)$ (4)
 > $\mathrm{Diffusion}\left(W\left(u\right)\right)$
 ${\mathrm{\sigma }}{}\left({u}\right)$ (5)
 > $\mathrm{Drift}\left(\mathrm{exp}\left(W\left(u\right)\right)\right)$
 ${\mathrm{\mu }}{}\left({u}\right){}{{ⅇ}}^{{\mathrm{_X1}}{}\left({u}\right)}{+}\frac{{{\mathrm{\sigma }}{}\left({u}\right)}^{{2}}{}{{ⅇ}}^{{\mathrm{_X1}}{}\left({u}\right)}}{{2}}$ (6)

Here is an example of a one-dimensional Brownian motion with time-dependent parameters given in algebraic form.

 > $\mathrm{\mu }≔\mathrm{piecewise}\left(t<1,0.02,\frac{0.02}{t}\right)$
 ${\mathrm{\mu }}{≔}\left\{\begin{array}{cc}{0.02}& {t}{<}{1}\\ \frac{{0.02}}{{t}}& {\mathrm{otherwise}}\end{array}\right\$ (7)
 > $\mathrm{\sigma }≔\mathrm{evalf}\left[3\right]\left(\mathrm{CurveFitting}:-\mathrm{Spline}\left(\left[\left[0,0.5\right],\left[1,0.3\right],\left[1.5,1.5\right],\left[2,1.0\right]\right],t,\mathrm{degree}=3\right)\right)$
 ${\mathrm{\sigma }}{≔}\left\{\begin{array}{cc}{0.500}{-}{1.40}{}{t}{+}{1.20}{}{{t}}^{{3}}& {t}{<}{1.}\\ {-}{1.90}{+}{2.20}{}{t}{+}{3.60}{}{\left({-}{1.}{+}{t}\right)}^{{2}}{-}{6.40}{}{\left({-}{1.}{+}{t}\right)}^{{3}}& {t}{<}{1.5}\\ {1.}{}{t}{-}{6.}{}{\left({t}{-}{1.5}\right)}^{{2}}{+}{4.}{}{\left({t}{-}{1.5}\right)}^{{3}}& {\mathrm{otherwise}}\end{array}\right\$ (8)
 > $Y≔\mathrm{BrownianMotion}\left(0.,\mathrm{\mu },\mathrm{\sigma },t\right):$
 > $S≔\mathrm{SamplePath}\left(Y\left(t\right),t=0..T,\mathrm{replications}={10}^{6}\right):$

Here is the same example but with drift and volatility given in the form of Maple procedures.

 > $\mathrm{\mu }≔\mathrm{unapply}\left(\mathrm{\mu },t\right)$
 ${\mathrm{\mu }}{≔}{t}{↦}\left\{\begin{array}{cc}{0.02}& {t}{<}{1}\\ \frac{{0.02}}{{t}}& {\mathrm{otherwise}}\end{array}\right\$ (9)
 > $\mathrm{\sigma }≔\mathrm{unapply}\left(\mathrm{\sigma },t\right)$
 ${\mathrm{\sigma }}{≔}{t}{↦}\left\{\begin{array}{cc}{0.500}{-}{1.40}{\cdot }{t}{+}{1.20}{\cdot }{{t}}^{{3}}& {t}{<}{1.}\\ {-}{1.90}{+}{2.20}{\cdot }{t}{+}{3.60}{\cdot }{\left({-}{1.}{+}{t}\right)}^{{2}}{-}{6.40}{\cdot }{\left({-}{1.}{+}{t}\right)}^{{3}}& {t}{<}{1.5}\\ {1.}{\cdot }{t}{-}{6.}{\cdot }{\left({t}{-}{1.5}\right)}^{{2}}{+}{4.}{\cdot }{\left({t}{-}{1.5}\right)}^{{3}}& {\mathrm{otherwise}}\end{array}\right\$ (10)
 > $Z≔\mathrm{BrownianMotion}\left(0.,\mathrm{\mu },\mathrm{\sigma }\right):$
 > $S≔\mathrm{PathPlot}\left(Z\left(t\right),t=0..T,\mathrm{replications}=10,\mathrm{axes}=\mathrm{BOXED}\right):$

Here is an example of a two-dimensional Brownian motion.

 > $\mathrm{X0}≔\mathrm{Vector}\left(\left[0.,0.\right]\right)$
 ${\mathrm{X0}}{≔}\left[\begin{array}{c}{0.}\\ {0.}\end{array}\right]$ (11)
 > $\mathrm{Μ}≔\mathrm{Vector}\left(\left[0.2,0.3\right]\right)$
 ${\mathrm{Μ}}{≔}\left[\begin{array}{c}{0.2}\\ {0.3}\end{array}\right]$ (12)
 > $\mathrm{\Sigma }≔\mathrm{Matrix}\left(\left[\left[1.0,0.05\right],\left[0.5,1.0\right]\right]\right)$
 ${\mathrm{\Sigma }}{≔}\left[\begin{array}{cc}{1.0}& {0.05}\\ {0.5}& {1.0}\end{array}\right]$ (13)
 > $W≔\mathrm{BrownianMotion}\left(\mathrm{X0},\mathrm{Μ},\mathrm{\Sigma }\right)$
 ${W}{≔}{\mathrm{_X4}}$ (14)
 > $\mathrm{SamplePath}\left(W\left(t\right),t=0..T,\mathrm{replications}={10}^{5}\right)$
 $\begin{array}{c}\left[\begin{array}{cc}{0.}& {0.}\\ {-0.136856108928577}& {-0.0574447282972881}\\ {0.}& {0.}\\ {-0.224919604989583}& {-1.17106664646595}\\ {0.}& {0.}\\ {0.966112744951698}& {1.03608756901477}\\ {0.}& {0.}\\ {1.78902994637680}& {0.192847957403796}\\ {0.}& {0.}\\ {0.318305385196534}& {-0.526664210024271}\\ {⋮}& {⋮}\end{array}\right]\\ \hfill {\text{slice of 100000 × 2 × 2 Array}}\end{array}$ (15)

You can simulate values for any path function given as a Maple procedure.

 > $V≔\mathrm{SampleValues}\left(X↦X\left[1,2\right]+X\left[2,2\right],W,0..T,\mathrm{replications}={10}^{5}\right):$
 > $\mathrm{Statistics}\left[\mathrm{DataSummary}\right]\left(V\right)$
 $\left[\begin{array}{c}{\mathrm{mean}}{=}{0.988749213777756}\\ {\mathrm{standarddeviation}}{=}{2.04881151111321}\\ {\mathrm{skewness}}{=}{0.00386575235144395}\\ {\mathrm{kurtosis}}{=}{2.99903802870409}\\ {\mathrm{minimum}}{=}{-7.10227512307098}\\ {\mathrm{maximum}}{=}{9.60382569520030}\\ {\mathrm{cumulativeweight}}{=}{100000.}\end{array}\right]$ (16)
 > $\mathrm{Statistics}\left[\mathrm{Histogram}\right]\left(V,\mathrm{bincount}=100\right)$ Here are examples involving stochastic volatility.

 > $R≔\mathrm{OrnsteinUhlenbeckProcess}\left(0.5,1.0,0.5,0.3\right)$
 ${R}{≔}{\mathrm{_X5}}$ (17)
 > $Y≔\mathrm{BrownianMotion}\left(0,0.,{R\left(t\right)}^{2},t\right)$
 ${Y}{≔}{\mathrm{_X7}}$ (18)
 > $\mathrm{PathPlot}\left(Y\left(t\right),t=0..3,\mathrm{timesteps}=100,\mathrm{replications}=10,\mathrm{axes}=\mathrm{BOXED},\mathrm{gridlines}=\mathrm{true}\right)$ Here is the same using different discretization schemes. For presentation purposes let us consider a Brownian motion with very low volatility and time-dependent drift. Compare the simulated results with the corresponding solution of an ordinary (non-stochastic) differential equation.

 > $f≔\mathrm{sin}\left(t\right)$
 ${f}{≔}{\mathrm{sin}}{}\left({t}\right)$ (19)
 > $\mathrm{W1}≔\mathrm{BrownianMotion}\left(0,f,0.001,t\right)$
 ${\mathrm{W1}}{≔}{\mathrm{_X8}}$ (20)
 > $\mathrm{W2}≔\mathrm{BrownianMotion}\left(0,f,0.001,t,\mathrm{scheme}=\mathrm{unbiased}\right)$
 ${\mathrm{W2}}{≔}{\mathrm{_X9}}$ (21)
 > $\mathrm{W3}≔\mathrm{eval}\left(y\left(t\right),\mathrm{dsolve}\left(\left\{\mathrm{diff}\left(y\left(t\right),t\right)=\mathrm{sin}\left(t\right),y\left(0\right)=0\right\}\right)\right)$
 ${\mathrm{W3}}{≔}{-}{\mathrm{cos}}{}\left({t}\right){+}{1}$ (22)
 > $\mathrm{plots}\left[\mathrm{display}\right]\left(\mathrm{plot}\left(\mathrm{W3},t=0..3\right),\mathrm{PathPlot}\left(\mathrm{W1}\left(t\right),t=0..3,\mathrm{timesteps}=10,\mathrm{replications}=10\right),\mathrm{thickness}=3,\mathrm{axes}=\mathrm{BOXED},\mathrm{gridlines}\right)$ > $\mathrm{plots}\left[\mathrm{display}\right]\left(\mathrm{plot}\left(\mathrm{W3},t=0..3\right),\mathrm{PathPlot}\left(\mathrm{W2}\left(t\right),t=0..3,\mathrm{timesteps}=10,\mathrm{replications}=10\right),\mathrm{thickness}=3,\mathrm{axes}=\mathrm{BOXED},\mathrm{gridlines}\right)$  References

 Glasserman, P., Monte Carlo Methods in Financial Engineering. New York: Springer-Verlag, 2004.
 Hull, J., Options, Futures, and Other Derivatives, 5th. edition. Upper Saddle River, New Jersey: Prentice Hall, 2003. Compatibility

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