mcs_full_vector_numpy.py has a drift a S[0]
joelowj opened this issue · 2 comments
Hi @yhilpisch, the fixed for #4 by setting the first time slice (t=0) to 0 does not correctly fixed the issue. On first look, it appears that it has solved the issue. However, on closer inspection of the equation, I notice that even though setting the first time slice (t=0) to 0, a drift will still be included at time slice resulting in an over-estimation.
With the current fixed, the results does not converge to the true price. I test the code and the results I obtain on multiple runs are hardly near the expected value 8.021352235143176.
Referencing back to the previous code,
S = S0 * exp(cumsum((r - 0.5 * sigma ** 2) * dt
+ sigma * math.sqrt(dt)
* random.standard_normal((M + 1, I)), axis=0))
On closer inspection, the problem with this piece of code is that, at time slice (t=0) it would have already ran a simulation 1 time. So the above code is running an additional simulation, a total of 51 (assuming M = 50).
So my proposed fix previously would be right,
S = S0 * exp(cumsum((r - 0.5 * sigma ** 2) * dt
+ sigma * math.sqrt(dt)
* random.standard_normal((M, I)), axis=0))
I ran the code you fixed vs the change proposed by me earlier in a 1k iteration and calculate the average price and obtain 8.052526426494092 vs 8.02133228814413.
I agree on the drift issue. In addition, convergence depends on more factors. I have now changed the respective code to include moment correction and also increased the number of iterations. It now shows good convergence.