Simulating a GBM Lognormal Price with the Correct Parameters
Summary
The document addresses how to simulate the terminal price of a geometric Brownian motion (GBM). It distinguishes the arithmetic mean and variance of the resulting lognormal price from the parameters required by a lognormal random-number generator, which are the mean and standard deviation of the underlying normal variable. Feeding price-level moments directly into that generator can therefore produce implausible draws.
The accepted explanation writes the terminal price as the initial price multiplied by an exponential containing drift and Brownian motion, and notes that the logarithm of the terminal price is normally distributed. This provides the right modeling approach: simulate the normal shock and transform it, or pass the corresponding log-space parameters to a lognormal sampler. However, the answer’s final parameter expression uses sigma times T for the normal standard deviation; for Brownian motion over horizon T, it should be sigma times the square root of T. The document therefore contains a useful distinction but an error in its final formula.
Key ideas
- A lognormal generator takes the mean and standard deviation of the underlying normal variable, not the price distribution’s moments.
- The logarithm of a GBM terminal price is normally distributed.
- The terminal price can be simulated by applying the GBM exponential transformation to a normal Brownian shock.
- For a time horizon T, the Brownian shock has standard deviation equal to the square root of T.
- The accepted answer’s final lognormal standard-deviation parameter omits that square root and is incorrect.
Tags
Full text
# Drawing values from a lognormal distribution of a GBM
# Drawing values from a lognormal distribution of a GBM
I'm looking at a GBM with parameters
$$ r=0.05 \\ \sigma=0.2 \\ K=130\\ T=0.25\\ S_0 = 100 $$
This is a process that is lognormally distributed with mean and variance given by
$ \mu = S_0e^{r T+0.5\sigma^2 T}\\ Var = S_0^2e^{2r T + \sigma^2T}(e^{\sigma^2 T}-1) $
I'm trying to generate values from this distribution. However, the values I get are quite:
```
r = 0.05
sigma = 0.2
K = 130
T = 0.25
S0 = 100
import numpy as np
mean = S0*np.exp(r*T)
var = np.sqrt((S0**2)*np.exp(2*r*T)*(np.exp((sigma**2)*T)-1))
np.random.lognormal(mean, np.sqrt(var))
```
Drawing values from $f(x)$ gives me something around $10^{45}$ (!) Can anybody spot my error in the above?
## Answer by emcor (score 3, accepted)
https://quant.stackexchange.com/a/50275
Assuming that your GBM is given by
$$S_{T}=S_{0}e^{(r -{\frac {\sigma ^{2}}{2}})T+\sigma W_{T}}$$
then its mean and variance are: $${Mean=S_{0}e^{r T},}$$ $$ {Variance=S_{0}^{2}e^{2r T}\left(e^{\sigma ^{2}T}-1\right)}{\displaystyle}$$
You cannot paste these values directly into np.random.lognormal because in this case the parameters $\mu$ and $\sigma^2$ do not represent the mean and variance of the random variable. You actually need to simulate $W_T\sim N(0,T)$ and plug these values into $S_T$.
For the Normal distribution it is only by coincidence that the estimator for $\mu$ and $\sigma$ are the mean and variance; the same does not hold for the Lognormal distribution https://docs.scipy.org/doc/numpy-1.14.1/reference/generated/numpy.random.lognormal.html:
"Draw samples from a log-normal distribution with specified mean, standard deviation, and array shape. Note that the mean and standard deviation are not the values for the distribution itself, but of the underlying normal distribution it is derived from."
To simulate from the Lognormal distribution of $S_T$, note that $\ln S_T$ is normally distributed: $$\ln S_{T}=\ln S_{0}+(r -{\frac {\sigma ^{2}}{2}})T+\sigma W_{T}\sim N(\ln S_{0}+(r -{\frac {\sigma ^{2}}{2}})T,\sigma T)$$
Hence you need to call:
```
np.random.lognormal(ln S_0+(r-sigma^2/2)*T, sigma*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.