MATLAB Language Univariate Geometric Brownian Motion


Example

The dynamics of the Geometric Brownian Motion (GBM) are described by the following stochastic differential equation (SDE):

enter image description here

I can use the exact solution to the SDE

enter image description here

to generate paths that follow a GBM.


Given daily parameters for a year-long simulation

mu     = 0.08/250;
sigma  = 0.25/sqrt(250);
dt     = 1/250;
npaths = 100;
nsteps = 250;
S0     = 23.2;

we can get the Brownian Motion (BM) W starting at 0 and use it to obtain the GBM starting at S0

% BM
epsilon = randn(nsteps, npaths);
W       = [zeros(1,npaths); sqrt(dt)*cumsum(epsilon)];

% GBM
t = (0:nsteps)'*dt;
Y = bsxfun(@plus, (mu-0.5*sigma.^2)*t, sigma*W);
Y = S0*exp(Y);

Which produces the paths

plot(Y)

enter image description here