In most cases the % error of mean is less than 5% but the error of std goes up to 30%. The required number of simulation I obtain is always less than 100, but % error of mean and std compare to mean and std of entire results is not always less than 5%. In my case I run the simualtion 7500 times, and compute moving means and standard deviations for each set of 100 sampling out of the 7500 simulations. So in this way it is possible to check that the resulting mean and standard deviation of $n$ simulations represent actual mean and standard deviation with 95% confidence level. N = \left\(x)$ is the standard deviation of the resulting sampling, and $z_c$ is the confidence level coefficient (e.g., for 95% it is 1.96). We often need to simulate diffusion process more generic than (D.My question is about the required number of simulations for Monte Carlo analysis method.Īs far as I see the required number of simulations for any allowed percentage error $E$ (e.g., 5) is 12 T = 5 nb_traj = 100 step = 1 / 255 = simplest_montecarlo ( mode, sigma, T, nb_traj, S0, mu, step ) figure ( ' Color ', ) plot ( t, S, ' linewidth ', 2 ) axis ( ) xlabel ( ' time ' ) ylabel ( ' value ' ) title ( sprintf ( ' %d trajectories', size(S,2))) >= mode = ' multiple ' T = 1 / 255 * 10 nb_traj = 2 step = 1 / 255 S0 = s = sigma = corr2cov ( s, ) mu = T = 5 nb_traj = 100 step = 1 / 255 = simplest_montecarlo ( mode, sigma, T, nb_traj, S0, mu, step ) figure ( ' Color ', ) subplot ( 2, 1, 1 ) plot ( t, reshape ( S ( :, 1, : ), size ( S, 1 ), size ( S, 3 ) ), ' linewidth ', 2 ) axis ( ) xlabel ( ' time ' ) ylabel ( ' value ' ) title ( sprintf ( ' %d trajectories - stock 1 (\\sigma=%5.2f%%)', size(S,3), s(1)*100)) subplot ( 2, 1, 2 ) plot ( t, reshape ( S ( :, 2, : ), size ( S, 1 ), size ( S, 3 ) ), ' linewidth ', 2 ) axis ( ) xlabel ( ' time ' ) ylabel ( ' value ' ) title ( sprintf ( ' %d trajectories - stock 2 (\\sigma=%5.2f%%)', size(S,3), s(2)*100)) A more generic Monte Carlo simulation in MATLAB call the main function in the correct mode.05, 1/255) switch lower ( mode ) case ' test - simple ' test_simplest_montecarlo case ' test - multi ' test_simplest_multiple_montecarlo case ) dWc = dW * Sdb c = repmat ( 1 + mu * step, nT, nb_traj ) S = S = reshape ( S, ) if nargout > 1 t = end Tests simplest simulationsĮach of those two blocks only call the main function. >= function = simplest_montecarlo ( mode, sigma, T, nb_traj, S0, mu, step ) % SIMPLEST_MONTECARLO - the simplest Monte Carlo simulation with Matlab % use: % S = simplest_montecarlo( mode, sigma, T, nb_traj, S0, mu, step) % example: % = simplest_montecarlo( 'simplest'. In this expression, δ t is the time step, is a correlated i.i.d. 12 T = 5 nb_traj = 100 step = 1 / 255 = simplest_montecarlo0 ( sigma, T, nb_traj, S0, mu, step ) figure ( ' Color ', ) plot ( t, S, ' linewidth ', 2 ) axis ( ) xlabel ( ' time ' ) ylabel ( ' value ' ) title ( sprintf ( ' %d trajectories', size(S,2))) Simplest Monte Carlo from scratch S is the price of the stocks, S 0 is their prices at the begining of the simulation,, σ their volatilities (annual), T is the length of the simulations ( step is the time step), and nb_traj is the number of trajectories to simulate. The goal is the simulation of trajectories of several stochastic process defined in (D.1). The parameters of a Monte Carlo simulation in finance Here is the simplest Monte Carlo possible using the basic functions of MATLAB (to understand the mechanisms of this simulation). The simplest Monte Carlo Simulation with Matlab Where r, σ and λ are constants of time and S.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |