       Re: Simulate and plot geometric brownian motion

• To: mathgroup at smc.vnet.net
• Subject: [mg122791] Re: Simulate and plot geometric brownian motion
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Thu, 10 Nov 2011 06:55:48 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <201111091122.GAA10781@smc.vnet.net>

```Try this:

Manipulate[SeedRandom[rr];
BlockRandom[
Module[{dB, dt = N[T/steps]},
dB = RandomReal[NormalDistribution[0, Sqrt[dt]], {paths, steps}];
ListLinePlot[
Transpose[
FoldList[#1 + #1*( \[Mu] dt + \[Sigma] #2) &,
ConstantArray[S0, {paths}], Transpose[dB]]],
DataRange -> {0, T}]]], {{steps, 50, "steps"}, 10, 500,
1}, {{T, 1, "time to expiry"}, 0.3, 3}, {{\[Mu], 0.3, "drift"}, 0,
1}, {{\[Sigma], 0.3, "volatility"}, 0,
1}, {{paths, 10, "number of paths"}, 1, 100,
1}, {{S0, 100, "starting price"}, 80, 120}, {{rr, 0, ""},
Button["new sample", rr = RandomInteger[2^64 - 1]] &},
SaveDefinitions -> True]

On 9 Nov 2011, at 12:22, Priyan Fernando wrote:

> 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.

```

• Prev by Date: Re: Graphics << Implicit vs ContourPlot
• Next by Date: More Efficient Use of Switch Statement
• Previous by thread: Simulate and plot geometric brownian motion
• Next by thread: Re: Simulate and plot geometric brownian motion