From de5875a75b335767bee9f2526856bb8c0ef0dfb8 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx,de>
Date: Sun, 12 Oct 2014 11:33:55 +0200
Subject: [PATCH] Fix bug still present in CutSample.m

#733 was faulty because it did not account for changes in the first line when more than 1 MH file was present. Now, FirstDraw really denotes the first draw (as opposed to the last draw as before). The subsequent computation of FirstMhFile is then also correct.
---
 matlab/CutSample.m | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/matlab/CutSample.m b/matlab/CutSample.m
index 11fdc09285..a3efbb01ad 100644
--- a/matlab/CutSample.m
+++ b/matlab/CutSample.m
@@ -52,9 +52,9 @@ end
 TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
 TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
 MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
-FirstDraw = max(1,floor(options_.mh_drop*TotalNumberOfMhDraws));
+FirstDraw = max(1,floor(options_.mh_drop*TotalNumberOfMhDraws)+1);
 FirstMhFile = ceil(FirstDraw/MAX_nruns);
-FirstLine = FirstDraw-(FirstMhFile-1)*MAX_nruns+1;
+FirstLine = FirstDraw-(FirstMhFile-1)*MAX_nruns;
 record.KeepedDraws.FirstMhFile = FirstMhFile;
 record.KeepedDraws.FirstLine = FirstLine;
 if (TotalNumberOfMhFiles-1)-(FirstMhFile+1)+1 > 0
@@ -74,5 +74,5 @@ fprintf('Estimation::mcmc: Total number of MH draws per chain: %d.\n',TotalNumbe
 fprintf('Estimation::mcmc: Total number of generated MH files: %d.\n',TotalNumberOfMhFiles);
 fprintf('Estimation::mcmc: I''ll use mh-files %d to %d.\n',FirstMhFile,TotalNumberOfMhFiles);
 fprintf('Estimation::mcmc: In MH-file number %d I''ll start at line %d.\n',FirstMhFile,FirstLine);
-fprintf('Estimation::mcmc: Finally I keep %d draws per chain.\n',TotalNumberOfMhDraws-FirstDraw);
+fprintf('Estimation::mcmc: Finally I keep %d draws per chain.\n',TotalNumberOfMhDraws-FirstDraw+1);
 skipline()
\ No newline at end of file
-- 
GitLab