function res = cons_experiments1_analyze(res, file) fid = fopen(file, 'w'); % consider statistics in the last delta steps delta = 100; for s=1:numel(res.scenarios) fprintf('\nScenario: %s\n\tAlgo\t\tDrift\t\tDisag\n', res.scenarios{s}{1}); for a=1:numel(res.algos) r = res.results{s,a}; algo_name = res.algos{a}{1}; scenario_name = res.scenarios{s}{1}; max_disag = max(r.disagreement(r.T-delta:r.T)); max_avg_disag = max_disag / (r.n * r.Delta); max_drift = max(abs(r.drift(r.T-delta:r.T))); fprintf('\t%s\t\t%.8f\t\t%.8f\n', algo_name, max_drift, max_avg_disag); i1 = 1; %last_index_above(abs(r.drift), max_drift); i2 = last_index_above(r.disagreement, 1.001*max_disag); fprintf('\t%s\t\t(%d)\t\t(%d)\n', res.algos{a}{1}, i1, i2); fprintf(fid,'\\newcommand{\\%sO%sO%s}{%.8f}\n', scenario_name, algo_name, 'drift', max_drift ); fprintf(fid,'\\newcommand{\\%sO%sO%s}{%.8f}\n', scenario_name, algo_name, 'disag', max_avg_disag); fprintf(fid,'\\newcommand{\\%sO%sO%s}{%d}\n', scenario_name, algo_name, 'drifti', i1 ); fprintf(fid,'\\newcommand{\\%sO%sO%s}{%d}\n', scenario_name, algo_name, 'disagi', i2); end drift_bound = 0.5 * r.eta; fprintf('\t d(k) <= %8.8f \n', drift_bound); e = eig(r.L); l_n = e(r.n); l_2 = e(2); avg_disag_bound = r.eta * sqrt(3/2) * (l_n / l_2); fprintf('\t dis(k) <= %8.8f \n', avg_disag_bound); fprintf(fid,'\\newcommand{\\%sO%sO%s}{%.8f}\n', scenario_name, algo_name, 'disagbound', avg_disag_bound); fprintf(fid,'\\newcommand{\\%sO%sO%s}{%.8f}\n', scenario_name, algo_name, 'driftbound', drift_bound); end function r = last_index_above(series, threshold) r = max(find(series>threshold)); if size(r) == 0 r = 1 end