0001 cd('..');
0002 boot;
0003 cd(cgmm_config.directories.main);
0004
0005
0006 n = 2
0007 dt = 1/250;
0008
0009
0010
0011 load(cgmm_config.estimates.wasc);
0012
0013
0014 mu = mu_cgmm
0015 Sigma_0 = Sigma_0_cgmm
0016 M = M_cgmm
0017 Q = Q_cgmm
0018 rho = rho_cgmm
0019 beta = round(beta_cgmm)
0020
0021
0022 S_0 = [100 100];
0023 y_0 = log(S_0);
0024 time_steps = cgmm_config.monte_carlo.time_steps/dt;
0025
0026
0027 [theta_flat_0, decode] = encode_wasc_param(mu, Sigma_0, M, Q, rho, beta);
0028
0029 cf = @(omega, th, y_t, tau) cf_wasc_v_theta(decode, omega, th, y_t, tau);
0030
0031 options = optimset('Display', 'iter' ...
0032 , 'Algorithm', 'interior-point');
0033
0034 lb = theta_flat_0 - abs(theta_flat_0)*0.1;
0035 ub = theta_flat_0 + abs(theta_flat_0)*0.1;
0036
0037
0038
0039
0040
0041
0042 simulation_runs = cgmm_config.monte_carlo.simulation_runs
0043 if exist(cgmm_config.monte_carlo.wasc)
0044 load(cgmm_config.monte_carlo.wasc);
0045
0046 first_run = size(estimates{1},1) + 1
0047 else
0048 estimates = {};
0049
0050 for k = 1:length(time_steps)
0051 estimates{k} = theta_flat_0;
0052 end
0053 first_run = 1
0054 end
0055
0056 for run = first_run:simulation_runs
0057 disp(strcat('Simulation run: ',num2str(run),'/',num2str(simulation_runs)));
0058 for k = 1:length(time_steps)
0059 t = 0:dt:(time_steps(k)*dt);
0060
0061 y = sim_wasc_2d(y_0, mu, Sigma_0, M, Q, rho, beta, t);
0062
0063 tic;
0064 [theta_flat_cgmm, theta_flat_first] = cgmm(y, dt, cf, theta_flat_0 ...
0065 , cgmm_config.cgmm.grid_min ...
0066 , cgmm_config.cgmm.grid_max ...
0067 , cgmm_config.cgmm.grid_res ...
0068 , lb, ub, options);
0069
0070 toc;
0071 estimates{k} = [estimates{k}; theta_flat_first];
0072 end
0073
0074 save(cgmm_config.monte_carlo.wasc, 'estimates', 'time_steps');
0075 end
0076