# Median value for geometric brownian motion simulation

I'm trying to simulate stock prices using GBM. I am using the following formula, and MATLAB function, to determine the stock prices:

$\nu = \mu - \frac{\sigma^{2}}{2}$;

$S = S0*\text{[ones(1,nsims); ... cumprod(}\exp(\nu dt+\sigma \sqrt{dt}*\text{randn(steps,nsims))},1)];$

using the following parameters:

$S0 = 1,$ $\mu = 0,$ $\sigma = 0.2481,$ $dt = 1/365,$ $\text{steps} = 365,$ $\text{nsims} = 1000.$

When I use this to generate the stock prices the results look log-normal and the log of the returns from the first to last price is also normal.

The issue I am having is that with no drift the median should be 1 according to http://en.wikipedia.org/wiki/Log-normal_distribution#Mode_and_median, but I am consistently getting values less than 1.

I am not sure what is going on or if I am simulating incorrectly.

This is my first time posting so please let me know if I have done anything incorrectly.

Thank you.

• I'm not sure exactly what you mean? All of the values are constants except for the standard normal value. I actually got a copy of this code from: goddardconsulting.ca/matlab-monte-carlo-assetpaths.html Could you point out exactly what is incorrect? – Robert Dec 17 '14 at 21:49
• The expected median is exp(-sig*sig/2). Since log is monotonic, median of log spot is log of median spot. Log spot is normally distributed so median equals mean. – q.t.f. Dec 17 '14 at 22:02
• But shouldn't the log normal's median be exp( mu ), while its mean is exp( mu - sig*sig/2)( en.wikipedia.org/wiki/Log-normal_distribution#Mode_and_median ). I was under the assumption that the resulting prices from a GBM are log-normal. What I'm curious about is that since a GBM with mu = 0 has a mean = S0, why isn't the median S0 as well? – Robert Dec 17 '14 at 22:09
• comparing wikipedia's notation to yours, your nu is their mu. – q.t.f. Dec 17 '14 at 22:11
• My nu = mu - sigsig/2. In Wikipedia they explicitly write out mu - sigsig/2. How do these differ? – Robert Dec 17 '14 at 22:14

You are generating a price series, in time steps $p_{dt},p_{2dt},p_{3dt},...$. I assume? So if you do $\text{Median}\{p_{dt},p_{2dt},p_{3dt},..\}$ then you will get a value biased towards $0$ (for the parameters you gave, and the sample size you have).
If you want to look at the distributional characteristics of the price, then you have to do so per each $p_{i \times dt}$, for a single $i$. So you create your price series, then isolate a particular $p_{i \times dt}$ and look at the distribution of that, over many samples.
So $\text{Median}\{p_{i\times dt}\}$ is equal to 1 (for all $i$).
If look at $\text{Median}\{p_{dt},p_{2dt},p_{3dt},..\}$ you are simply getting the median of a log-normal mixture distribution (with a really small sample size), which I guess is not what you want.
• yes. Each price increment comes from a different distribution, in effect. $p_{1*dt}$ has lower variance than $p_{100 dt}$, if you imagine current time price to be $p_{0}$. Accept the answer if its correct for you. – Rusan Kax Dec 18 '14 at 12:17