# Are my estimates of parameters of geometric brownian motion correct?

I wrote a simulation of a geometric Brownian motion which works like this:

1. ${ t }_{ i }-{ t }_{ i-1 } \sim Exp(\lambda )$
2. ${ Z }_{ i }\sim N(0,1)$
3. ${ Y }_{ i }\sim { e }^{ \sigma \sqrt { { t }_{ i }-{ t }_{ i-1 } } { Z }_{ i }+\left( \mu -\frac { { \sigma }^{ 2 } }{ 2 } \right) \left( { t }_{ i }-{ t }_{ i-1 } \right) }$
4. $S({ t }_{ 1 })=S({ t }_{ 0 })\times { Y }_{ 1 }$
5. $S({ t }_{ 2 })=S({ t }_{ 1 })\times { Y }_{ 2 }=S({ t }_{ 0 })\times { Y }_{ 1 }\times { Y }_{ 2 }$
6. $S({ t }_{ k })=S({ t }_{ k-1 })\times { Y }_{ k }=S({ t }_{ 0 })\times { Y }_{ 1 }\times { Y }_{ 2 }\times\dots \times{ Y }_{ k }$

In order to verify that my code is correct, I tried to estimate the parameters of my simulation from samples taken from it.

My parameter estimation strategy was like this:

I knew $\mathrm{E}[{ t }_{ i }-{ t }_{ i-1 }] = \frac{1}{\lambda}$

Since $\ln { \frac { S({ t }_{ i+1 }) }{ S({ t }_{ i }) } \sim N(\tilde { \mu } ,\tilde { \sigma } ) }$, I just used the parameter estimation techniques for normal distributions to estimate $\tilde { \mu }$ and $\tilde { \sigma }$.

Since $\tilde { \sigma } = \sigma \sqrt{ { t }_{ i }-{ t }_{ i-1 }}$, I reasoned that $\sigma = \frac { \tilde { \sigma } }{ \sqrt{ \mathrm{E}[{ t }_{ i }-{ t }_{ i-1 }]} }$

Since $\tilde { \mu } = \left( \mu -\frac { { \sigma }^{ 2 } }{ 2 } \right) \left( { t }_{ i }-{ t }_{ i-1 } \right)$, I reasoned that $\mu = \frac { \tilde { \mu } }{ \mathrm{E}[{ t }_{ i }-{ t }_{ i-1 }] } + \frac { { \sigma }^{ 2 } }{ 2 }$ where I used the $\sigma$ estimated from above.

Is my logic correct? I did not use any formal reasoning, so I am not confident my method for estimating parameters is correct. Can someone help me?

This is not homework. I am just trying to write program which behaves like the financial markets.

First to point this out. You do not simulate standard geometric Brownian motion but time-changed GBM where the distribution of time is an exponential distribution with parameter $\lambda$ independent of the GBM.
Using the technique of time change one usually assumes that the expected time is unbiased. If you write each time interval as $$(t_i - t_{i-1}) \Lambda_i$$ with $\Lambda_i \sim Exp(\lambda)$ one usually assumes that $E[ (t_i - t_{i-1}) \Lambda_i] = t_i - t_{i-1}$, and thus in short that $E[\Lambda_i ] = 1$. This can only be achieved if you use $\Lambda_i \sim Gamma(1/\lambda,1/\lambda)$.
You were on the right track. Define $X_i = \ln(S_{t_i}/S_{t_{i-1}}))$. This process is a variance-gamma process with drift. You find ways to calibrate this process on the mentioned wikipedia page.
With the additional parameter $\lambda$ it does not suffice to look at expected value and variance only. You need one higher moment - usually kurtosis.