% configuracni struktura se bude jmenovat "c"
c.b =1;
c.sigma = 0.1;
c.ndat = 50;
yr = 1;

% nejlepsi mozny regulator - zna b
C1.class='exact_ctrl';
C1.yr   = yr;
C1.b    = c.b;

% CE regulator - b se odhaduje
C2.class='ce_ctrl';
C2.yr   = yr;
C2.b0   = 0;
C2.P0   = 1;

% monte carlo study
n=100;
losses=zeros(10,1);
seeds=32000*rand(1,n);
for i=1:n
    c.b = randn();
    c.seed = seeds(i); 
    c.controller = C1;
    Mmc=iterativemc(c);
    losses(i) = sum((Mmc.S_y-yr*ones(size(Mmc.S_y))).^2);
    
    c.controller = C2;
    Mmc=iterativemc(c);
    looo= sum((Mmc.S_y-yr*ones(size(Mmc.S_y))).^2)
%     keyboard
    losses2(i) = looo;
end
[min(losses) median(losses) max(losses)]
[min(losses2) median(losses2) max(losses2)]

