1
$\begingroup$

I am trying to write a simple GBM simulator. Unfortunately, the task has turned rather difficult.

The first approach I looked into was the most obvious. I could use the analytic solution for the GBM found here:

$S_t = S_0exp((\mu - \frac{\sigma^2}{2})t + \sigma W_t)$

This is relatively straight-forward in implementation except the $W_t$, the $t$-th observation from a brownian process. Following the direction of this tutorial on brownian motion left me lost as to it's implementation. It seemed to be:

  1. Simulate a brownian process from $W_0$ to $W_t$
  2. For each $x$ from $0$ to $t$ use $W_x$ to solve for $S_x$

This seemed excessively complicated compared to what I remembered from doing simulations a few years back. Stumbling on this article I came across an interesting formula I've seen before:

$\frac{\Delta S}{S} = \mu \Delta t + \sigma \epsilon \sqrt{\Delta t}$

Where $\epsilon$ is a shock drawn from the standard normal distribution $N(0, 1)$. $\Delta t$ is obviously the change in time from $S_t$ to $S_{t + \Delta t}$. Perhaps for daily data $\Delta t = 1$. This is a little closer to what I remember - though there's no brownian component here - $W_t$. Where did it go?

I am unsure which of these I should use that would be more correct. Currently I'm relearning stochastic calculus after many years and am inclined to use the SDE (if I could figure out how to simulate brownian motion easily!). However, the simpler second solution intrigues me as well if I could figure out how it is derived.

$\endgroup$
1
  • $\begingroup$ Please define your abbreviations on first use. GBM can also mean "gradient boosted model", and I had no idea what your post was talking about until I read the answer. $\endgroup$ Commented Aug 8, 2018 at 14:43

2 Answers 2

1
$\begingroup$

The geometric Brownian motion is defined by the SDE:

$$dS_t = \mu S_tdt + \sigma S_tdW_t$$

The first formula you show is the exact, analytic solution to this equation. The second formula is an approximation to the SDE known as the Euler-Maruyama method in general. Basically, replace infinitesimal increments by small deltas, and evaluate the drift and diffusion functions at the start of the interval (i.e. at $t$), like this:

$$S_{t+\Delta t} - S_t= \mu S_t\Delta t + \sigma S_t \left(W_{t+\Delta t}-W_t\right)$$

By definition of the Brownian motion, the increments are distributed as:

$$W_{t+\Delta t}-W_t \sim \mathcal{N}(0,\Delta t)$$

So if we let $\varepsilon_t \sim^{\text{iid}} \mathcal{N}(0,1)$, this is the same as what you have:

$$S_{t+\Delta t} - S_t= \mu S_t\Delta t + \sigma S_t \left(\sqrt{\Delta t}\varepsilon_t\right)$$

That is, the $\sqrt{\Delta t}\varepsilon_t$ is "where the $W_t$ went".

In the case of this specific equation, the Euler-Maruyama method is not necessary because, as you mentioned, we have an exact formula. The only issue is how to simulate $W_t$. This is not particularly difficult since the increments $W_{t+\Delta t} - W_t$ are independent and normally distributed, so you can just draw independent normal variates with variance $\Delta t$, and then compute the cumulative sum to get $W_t$ for every $t$ that you need. Once you have a path for $W_t$, plug it in to the analytic solution to get a path for $S_t$.

$\endgroup$
1
  • $\begingroup$ Ah, replacing the infintessimal increments by small increments must be discretization. Thank you. $\endgroup$
    – lolo
    Commented Aug 8, 2018 at 13:40
0
$\begingroup$

The best course of action is simulate Brownian motion via

$ W_0 = 0, $

$ W_{t+\Delta t} = W_t + \sqrt{\Delta t}\ \rm{N(0,1)} $

and then plug it into the very first formula that you mentioned:

$ S_t = S_0 \exp((μ − σ^2 / 2)t + \sigma W_t). $

With $\Delta t$ small enough you will get quite realistic trajectories, like these.

$\endgroup$
4
  • $\begingroup$ The bit about "with $\Delta t$ small enough" could be confusing because the process you describe is exact and works for any $\Delta t$, whereas the Euler-Maruyama approximation also mentioned in the question does require small increments to give a good approximation. $\endgroup$
    – Chris Haug
    Commented Aug 8, 2018 at 12:36
  • $\begingroup$ @Chris Haug If we know the frequency of cashflows (say daily) and want only to price, we can set $\Delta t$ to that. But in exploratory analysis, if we want to see what's going on, realistic trajectories help. Before knowing anything it is best to set $\Delta t$ to something small. Especially because with GBM computational demands are tiny. That is what I meant. $\endgroup$
    – stans
    Commented Aug 8, 2018 at 12:44
  • $\begingroup$ There are no references to cash flows or the use of GBM as a model in the question at all. It is strictly about simulating a stochastic process. So, there is no concept of "realistic" here at all. What's more is that many processes (e.g. stock prices) are especially not well-modelled by GBM on very small time scales, but only on longer ones, so that seemed like weird advice to me. $\endgroup$
    – Chris Haug
    Commented Aug 8, 2018 at 13:15
  • $\begingroup$ Exactly, we don't know the context of the problem at all. So any extra assumptions would be precarious here. Until we learn more the step should be set small... Pricing future cashflows was only an example in response your comment. And regarding your "financial insight" about GBM, well, based on my 10+ years in the finance industry GBM is not good for almost anything when it comes to real pricing or real trading. But that was not the question of our friend. $\endgroup$
    – stans
    Commented Aug 8, 2018 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.