I hope this is the right section for this kind of questions.
I am trying to simulate, with MATLAB, a diffusion model starting from a Random Walk. I am using a Random Walk with information increment X normally distributed ($\mu, \sigma$ ). I also have a boundary $\alpha $, and $\alpha > \mu$. The starting point is 0.
If I understood this right, this should be an approximation of the Wiener Process. As wikipedia says (http://en.wikipedia.org/wiki/Inverse_Gaussian_distribution), the first passage time for a fixed level $\alpha > 0 $by $X_t$ is distributed according to an inverse-gaussian: $ T_\alpha = \inf\{ 0 < t \mid X_t=\alpha \} \sim IG(\tfrac\alpha\nu, \tfrac {\alpha^2} {\sigma^2}).\, $
What I am trying to do is to simulate a Random Walk and to get the first passage time distribution, verifying that it is actually a Inv. Gaussian with those parameters.
This is the code I have done: http://pastebin.com/E1N58sJ4
Notice that the myHist function is commented, but I normally use it: in that function I fit the resulting distribution to an inverse gaussian. Then I compare the fitted parameters with the two parameters obtained by the formula showed above, $\mu= \alpha/v $ and $ \lambda= \alpha^2/\sigma^2 $
However, the two results are NOT THE SAME, and they differ consistently across simulation. For example, with the parametrers used in the code:
Simulation - mu:29.1771 s: 116.7757 Expected - mu:26.3158 s: 100
This difference is consistent across repetition of simulation.
Can anyone spot the mistake?
{I wrote this question in CrossValidated, but I deleted the post there and I put it here, because it seems more appropriate. One -not definitive- answer that I've got regarded the time step size of my function. Unfortunately, I don't know how to change that, so if you could provide some help with the implementation that would be much appreciated}