function LoopMCMCIndependentSampler(nexptos,N) 

% LOOPMCMCMINDEPENDENTSAMPLER Runs the Inpepedent Sampler algorithms mutiple times
%
% LoopMCMCIndependentSampler(nexptos,N)
% nexptos: number of times
% N: array with number of samples


% APRENDIZAJE AUTOMÁTICO (G. Pajares y J. M. de la Cruz, Eds.)
% Editorial: RA-MA
% Capítulo 7 y 8: Monte Carlo I y II
% Autores: Eva Besada-Portas, Sergey M. Plis

 draw=0;                   % Draw results inside each method
 
 pfun=DefineFunction('pC'); %pfun funtion 
  
 load StartMCMCData %s0
 snew=s0;

 hmN=length(N);
 fmean={};
 for l=1:hmN
    N(l)               
    for k=1: nexptos
        disp(sprintf('Experiment:%d',k));
   
      
        s0 = snew(k,l);
        
        limit=[10,90];
        qfun=DefineFunction('quniform',limit);
        [samplesMC]=MarkovChain(N(l),DefineFunction('ChainIndependentSampler',pfun,qfun),s0,draw);
        fmean{1}(k,l)=mean(samplesMC);
          
        mu    = 43.5;
        sigma = 15;
        qfun=DefineFunction('qgaussian',mu,sigma);
        [samplesMC]=MarkovChain(N(l),DefineFunction('ChainIndependentSampler',pfun,qfun),s0,draw);
        fmean{2}(k,l)=mean(samplesMC);
                    
    end
 end


save('LoopMCMCIndependentSamplerData','fmean','pfun','N');

 