clear all
close all
settings = createSettings();

% ------------------------------------------------------------------------
% Parameters
a = .9;
b = .1;
sigma = .25;
settings.param = [a, b, sigma];
settings.nStep = 30000;

% ------------------------------------------------------------------------
% Settings
[x,y] = createData(settings.nStep,a,b,sigma);
settings.x = x;
settings.y = y;
settings.nStep = length(x); 
settings.store = true;

% ------------------------------------------------------------------------
% Test runs
NMC = 1;
settings.N = 2^10;
settings.silent = true;
settings.resetFigs = false;
essThresholds = .6;
nTH = length(essThresholds);

nFnc = 1;
fnc = 1;
burnIn = 100;

methodNames = {'ARPF','Simple','Greedy','SimpleRearrange'};
methodLabels = {'adaptiveBootstrap','blockstrategy1','greedy','SimpleRearrange'};
progressLabels = {'Running adaptive bootstrap',...
    'Running alpha SMC with block strategy',...
    'Running alpha SMC with greedy strategy',...
    'Running alpha SMC with simple strategy with rearranging'};
nMethod = length(methodLabels);

ESS = cell(nMethod,1);
NSTRATA = cell(nMethod,1);

for meth = 1:nMethod
    
    fprintf('%s\n',progressLabels{meth});
    settings.method = methodLabels{meth};

    for th = 1:nTH
        
        fprintf('\tESS threshold %6.2f ',essThresholds(th));
        settings.essThreshold = essThresholds(th);
        
        for k = 1:NMC
            
            fprintf('.');
            [X,MU,MUW,ess,NSTRATA{meth},W,essc] = alphaSMC(settings);
            ESS{meth} = ess;
            ESSC{meth} = essc;
        end
        fprintf('Done\n');
    end
end

% Level of interaction i.e. samples per stratum
interaction = {settings.N ./ NSTRATA{1}, settings.N ./ NSTRATA{2},...
    settings.N ./ NSTRATA{3}, settings.N ./ NSTRATA{4}};

mu1 = log2(mean(interaction{1}((burnIn+1):end)));
mu2 = log2(mean(interaction{2}((burnIn+1):end)));
mu3 = log2(mean(interaction{3}((burnIn+1):end)));

save(['smallrun' datestr(now,'yyyy-mm-dd-HH-MM-SS') '.mat']);

