-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Last isave steps not written to file #10
Comments
This bug is still here. Currently the last |
I discovered this independently just now. Here's an analysis: Suppose you say you want 100,000 samples, and isave is the default 1000. The first sample is the initial sample. Thus the sampler takes 99,999 steps and finishes. The initial sample has iter=0. The final sample has iter=99,999, and since this isn't a multiple of isave, it isn't written out. The last write takes place at iter=99,000 and writes samples numbered 98,000...98,999. Samples 99,000...99,999 are never written. You might think you could work around this by requesting 100,001 samples, but then it crashes because of issue #20. In my opinion, the right fix is to make Niter the number of steps that you are requesting, i.e., the number of samples not including the initial one. Then the number of samples written out will be Niter/thin + 1. I would write the initial sample immediately, then call writeToFile with iter=1000, 2000, ..., 100,000, with each call writing the last 100 (i.e., isave/thin) samples numbered iter-isave+10, iter-isave+20, ..., iter. |
So basically you propose to define Niter as the number of "steps" not "posterior evaluations". I think that's a good way to think about it, I don't mind that at all. I can't think of a case where outputting Niter/thin + 1 samples would suddenly break stuff down the line. Usually, when reading in a MCMC chain, you determine the number of samples from the file, not in any other way. @kdolum, if you feel like making a PR or work with @paulthebaker on #21, then please go ahead. |
OK. I will make a PR fixing this and also #20. I'll make sure not to lose @paulthebaker's changes in #21.
If you have any objections to these choices, please let me know. |
Thanks for your attention and work on this! For what it's worth, I agree with @kdolom's plan. I am not an expert on parallel tempering, but as an FYI, a departed colleague of mine recently documented her PTMCMCSampler-based code with the expectation that the number of samples being generated should be +1 for clarity / documentation on the # of samples saved |
I think the problem is that |
Fixed by #41. |
Standard isave=1000. Last 1000 steps are not written to the chain file.
The text was updated successfully, but these errors were encountered: