Correcting the Diffusion Term in a GBM Simulation
Summary
This exchange diagnoses a dimensional error in a one-step geometric Brownian motion simulation. The closed-form process uses a drift term of (μ − σ²/2)T and a random term of σ√T multiplied by a standard normal shock. The code in the question instead multiplies the shock by σ²√T, so the simulated distribution does not follow the stated GBM model and its sample average need not match the expected value derived for that model.
The answer identifies the extra power on volatility and gives the equivalent diffusion scale √(σ²T) = σ√T. The reported sample mean is based on a finite set of random draws, so it would not by itself establish a model error; here, the formula typo is the concrete issue. The exchange does not discuss repeated simulation, sampling error, or validation beyond correcting this term.
Key ideas
- In a GBM step, the random shock is scaled by volatility times the square root of elapsed time.
- The drift correction in the exponent is (μ − σ²/2)T.
- Multiplying the shock by volatility squared changes the simulated process.
- A finite simulation average can differ from the theoretical expectation due to sampling variation.
Tags
Full text
# What is wrong in this GBM simulation?
# What is wrong in this GBM simulation?
I am trying to generate a few samples of GBM using the following very simple MATLAB code:
```
function results=gbm(mean,vol,s0,T,shocks)
results = s0 * exp( (mean - vol^2/2) * T + vol^2 * sqrt(T) * shocks);
```
As you can see, I am using directly the closed form solution of the wiki page.
The thing is, I know that techincally $\mathbb{E}(S_t) = S_0 \exp(\mu t)$, but when I do:
```
mean(gbm(0,.1,100,1,randn(1000,1)))
```
I get `99.54` as a result. How can that be?
I mean in the code above, I use $\mu=0$, so I'm expecting $\mathbb{E}(S_t) = S_0 \exp(0 )=S_0$
I've been looking at this too much and there might be something obvious I'm missing here.
## Answer by emcor (score 4, accepted)
https://quant.stackexchange.com/a/14618
You have typo "vol^2", but it should be "vol".
Its $$\sqrt{\sigma^2T}=\sigma\sqrt{T}$$Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.