0001 function CutSample()
0002
0003 global M_ options_ estim_params_
0004
0005 npar = estim_params_.np+estim_params_.nvn+estim_params_.ncx+estim_params_.ncn+estim_params_.nvx;
0006
0007 DirectoryName = CheckPath('metropolis');
0008 file = dir([ DirectoryName '/' M_.fname '_mh_history.mat']);
0009 files = dir([ DirectoryName '/' M_.fname '_mh*.mat' ]);
0010 if ~length(files)
0011 disp('MH:: FAILURE! there is no MH file to load here!')
0012 return
0013 end
0014 if ~length(file)
0015 disp('MH:: FAILURE! there is no MH-history file!')
0016 return
0017 else
0018 load([ DirectoryName '/' M_.fname '_mh_history'])
0019 end
0020 TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
0021 TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
0022 MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8)
0023 FirstDraw = floor(options_.mh_drop*TotalNumberOfMhDraws);
0024 FirstMhFile = ceil(FirstDraw/MAX_nruns);
0025 FirstLine = FirstDraw-(FirstMhFile-1)*MAX_nruns+1;
0026 record.KeepedDraws.FirstMhFile = FirstMhFile;
0027 record.KeepedDraws.FirstLine = FirstLine;
0028 if (TotalNumberOfMhFiles-1)-(FirstMhFile+1)+1 > 0
0029 record.KeepedDraws.Distribution = [ MAX_nruns-FirstLine+1 ; ...
0030 ones((TotalNumberOfMhFiles-1)-(FirstMhFile+1)+1,1)*MAX_nruns ; ...
0031 record.MhDraws(end,3) ];
0032 elseif TotalNumberOfMhFiles == 1
0033 record.KeepedDraws.Distribution = [];
0034 elseif TotalNumberOfMhFiles == 2 & FirstMhFile > 1
0035 record.KeepedDraws.Distribution = [MAX_nruns-FirstLine+1 ; record.MhDraws(end,3)];
0036 end
0037 save([DirectoryName '/' M_.fname '_mh_history'],'record');
0038 fprintf('MH: Total number of Mh draws: %d.\n',TotalNumberOfMhDraws);
0039 fprintf('MH: Total number of generated Mh files: %d.\n',TotalNumberOfMhFiles);
0040 fprintf('MH: I''ll use mh-files %d to %d.\n',FirstMhFile,TotalNumberOfMhFiles);
0041 fprintf('MH: In mh-file number %d i''ll start at line %d.\n',FirstMhFile,FirstLine);
0042 fprintf('MH: Finally I keep %d draws.\n',TotalNumberOfMhDraws-FirstDraw);
0043 disp(' ');