[Date Index]
[Thread Index]
[Author Index]
Re: Simulate and plot geometric brownian motion
*To*: mathgroup at smc.vnet.net
*Subject*: [mg122781] Re: Simulate and plot geometric brownian motion
*From*: "Dr. Wolfgang Hintze" <weh at snafu.de>
*Date*: Thu, 10 Nov 2011 06:53:59 -0500 (EST)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*References*: <j9do82$b1r$1@smc.vnet.net>
"Priyan Fernando" <priyan.fernando at gmail.com> schrieb im Newsbeitrag
news:j9do82$b1r$1 at smc.vnet.net...
> Hi
>
> Wonder if you could please help me simulate and plot geometric
> brownian
> motion (GBM)
>
> E.g. dS = mew * S dt + sigma * S *dX
>
> What I am trying to do is generate in Mathematica the process for a
> stock/share price based on GBM
>
> Therefore:
> dS is change in share price
> S is the share price (e.g. let S start from 100)
> dt is the time step (e.g. in discrete version we could have dt=1/52
> so
> timestep is 1 week)
> mew is the drift (e.g. mew = 5%)
> sigma is the volatility (e.g. sigma = 10%)
> dX is brownian motion (e.g. in discrete version, dX = Sqrt(dt) *
> N(0,1))
>
> What I am trying to obtain is pairs (x,y) where x is the time step
> and y is
> the share price. And then to be able to plot this.
>
> Thanks for your help,
> Priyan.
Below you find an example of a code for your problem.
Your model has been literally translated.
You can play around with the parameters.
Notice specifically the strong influence of the drift.
If mu is large enough (and sigma not too big) the share price
explodes exponentially after a certain time.
Enjoy.
Regards,
Wolfgang
<< "Statistics`ContinuousDistributions`"
(* Parameters of process *)
dt = 1./52;
\[Mu] = 2./100;
\[Sigma] = 10./100;
(* parameters of run *)
y = 100; (* time span in years *)
n = 52*y; (* time steps *)
s[0] = 100; (* initial share price *)
t = 0; (* time *)
(* calculate time development and store in list p *)
p = Table[{t = t + dt, s[k] = s[k - 1] + dt*\[Mu]*s[k - 1] +
\[Sigma]*s[k - 1]*Sqrt[dt]*Random[NormalDistribution[0, 1]]}, {k, 1,
n}];
(* plot result *)
ListPlot[p, AxesLabel -> {"Time (years)", "rel. \nshare \nprice"},
PlotLabel -> StringJoin["Development of share price\naccording to model
(ds \[LongEqual] \
dt s \[Mu] + \[Sigma] s dX)\nParameters: \ndt = ", ToString[dt],
"\n\[Mu] = ",
ToString[\[Mu]], "\n\[Sigma] = ", ToString[\[Sigma]]]];
Prev by Date:
**Re: AspectRatio -> 1 vs AspectRatio ->1.25**
Next by Date:
**Re: Import files on accessible URL and save in**
Previous by thread:
**Re: Simulate and plot geometric brownian motion**
Next by thread:
**Manipulate Slider not Moving**
| |