Monte Carlo Project

Dear All,



I am trying to run some Monte Carlo simulations, in order to simulate the share price path and from there to calculate the vanilla call option price.



I managed to the most part, except for one line of code I dont understand why that doesnt work, please see below:



np.random.seed(0)

#Empty arrays which can be used to store estimate values for different sample sizes

mcall_estimates = [None]*50

mcall_std = [None]50



for i in range(1,51):

    mcall_val = np.array(analytic_callprice(paths, K, T, sigma, r))

    mcall_estimates[i-1] = np.mean(mcall_val)

    mcall_std[i-1] = np.std(mcall_val)/np.sqrt(i
1000)





The mcall_estimates should calculate the Monte Carlo estimate for the given sample size. It does work for mcall_std, but for mcall_estimates I get the same number. I cannot figure out why.





I will share the code I have so far, you should find this in part 3. Also with some explanation o



Any help is appreciated.

Thanks in advance.

Ben

Hi Mart,



In every step of the loop, you are sending exactly same inputs to analytic_callprice() function and hence the value of mcall_val is same for all steps of the loop. 



Since the value of mcall_val doesn't change, you are getting same results from np.mean(mcall_val) for every elements of mcall_estimates as np.mean() takes the mean of all the elements included in mcall_val.



If you wonder why this doesn't work in the same way for mcall_std, actually it does. You are getting different values for every element in the mcall_std because of the division:



     np.sqrt(i*1000)



Since i changes in every step of the loop, the elements of the mcall_std are different from each other although np.std(mcall_val) is constant.



Hope this helps.

 

 

Hi Suleyman,



I managed to figure this out, but thank you for your answer. 



Best Regards.