function [sigmas, vars, H0_mean, H0_max, H1_mean, H1_max] = get_sigma_var(recovery_results, sigma_w2, x) sz = size(recovery_results); trail_times = sz(2); sigmas = zeros(2, trail_times); vars = zeros(2, trail_times); id = 1; for T = 1:trail_times x_0_hat = squeeze(recovery_results(1, T, :)); x_1_hat = squeeze(recovery_results(2, T, :)) - x; if anynan(x_1_hat) continue; end % if sigma_w2(2, T) > 0.1 % continue; % end sigmas(1, id) = sigma_w2(1, T); sigmas(2, id) = sigma_w2(2, T); vars(1, id) = var(x_0_hat); vars(2, id) = var(x_1_hat); id = id + 1; end sigmas(:, end - trail_times + id: end) = []; vars(:, end - trail_times + id: end) = []; REE = abs(vars - sigmas) ./ vars; H0_mean = mean(REE(1, :)); H0_max = max(REE(1, :)); H1_mean = mean(REE(2, :)); H1_max = max(REE(2, :)); if 1 == 9 figure; subplot(211); plot(sigmas(1, :)); hold on; plot(vars(1, :)); xlabel("Mento Carlo Times"); ylabel("\sigma^2") legend("\sigma^2 (CROD)", "\sigma_w^2 (Expr)"); subplot(212); plot(sigmas(2, :)); hold on; plot(vars(2, :)); xlabel("Mento Carlo Times"); ylabel("\sigma^2"); legend("\sigma^2 (CROD)", "\sigma_w^2 (Expr)"); figure; subplot(211); plot(REE(1, :)); yline(H0_mean); xlabel("Mento Carlo Times"); ylabel("REE"); legend("mean = " + string(H0_mean), "max = " + string(H0_max)); subplot(212); plot(REE(2, :)); yline(H1_mean); xlabel("Mento Carlo Times"); ylabel("REE"); legend("mean = " + string(H1_mean), "max = " + string(H1_max)); end end