function best_control=compare_candidates(start,candidates,H,u,rsss_parameters,yr,sigma) %hledam minimum rinott=3; student=5; %n0 prvnich realizaci realization1=zeros(size(candidates,1),rsss_parameters.n0); for i=1:size(candidates) for j=1:rsss_parameters.n0 realization1(i,j)=generate_realization(start,candidates(i),H,u,sigma,yr); end end %pomocne veliciny mean_values=mean(realization1,2); variances=sum((realization1-mean_values*ones(1,rsss_parameters.n0)).^2,2)/(rsss_parameters.n0-1); W=student*sqrt((variances*ones(1,size(candidates,1))+ones(size(candidates,1),1)*variances')/rsss_parameters.n0); %selekce kadnidatu pro druhou fazi RSSS pass=zeros(size(candidates,1),1); for i=1:size(candidates) pom=true; for j=1:size(candidates) % max(realization1); %max(0,W(i,j)-rsss_parameters.delta) if (mean_values(i)>10*min(mean_values)) pom=false; end if (pom && -mean_values(i)<-mean_values(j)-max(0,W(i,j)-rsss_parameters.delta)) %hledam minimum pom=false; end end pass(i)=pom; end if sum(pass)>1 sum(pass); %druha faze RSSS best_control=0; for i=1:size(candidates) if (pass(i)) poc=(-floor(-variances(i)*(rinott/rsss_parameters.delta)^2)); poc=min(1000,poc); realization2=zeros(1,poc); for j=1:size(realization2,2) realization2(j)=generate_realization(start,candidates(i),H,u,sigma,yr); end mean_values(i)=mean(realization1(i))+mean(realization2); if (best_control && mean_value(i)>mean_value(best_control)) best_control=i; end end end else [pom,best_control]=max(pass); end end