Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upCommonly used adaptation methods #20
Conversation
Adding a class containing commonly used parameters and methods to adapt them (for static Bayesian models).
|
Nice -- you are clearly getting the drift of incremental value-added PRs. We're in a good spot now. I'll wait for Adam to peek at this tomorrow though before I merge. |
|
This looks good to me. There are a few small things it might make sense to tweak, particularly in the acceptProb comparisons (not that I'd expect these to have any significant impact). |
| /// \param desiredCESS The target conditional ESS for the next temperature (generally fixed). | ||
| void staticModelAdapt::ChooseTemp(const arma::vec & logweight, const arma::vec & loglike, double desiredCESS) { | ||
| double temp_curr = temp.back(); | ||
| if (CESSdiff(logweight,loglike,1-temp_curr,desiredCESS)>=0){ |
adamjohansen
Aug 7, 2017
Collaborator
Might it make sense for the comparison to be with -0.01 (or the tolerance) to be consistent with the inner workings of the bisection function?
Might it make sense for the comparison to be with -0.01 (or the tolerance) to be consistent with the inner workings of the bisection function?
| m = (a+b)/2.0; | ||
| f_m = CESSdiff(logweight,loglike,m-curr,desiredCESS); | ||
| err = 10; | ||
| while (err > 0.01){ |
adamjohansen
Aug 7, 2017
Collaborator
It might be good if it were possible to choose this tolerance without changing a hard-coded constant. In some applications the desired CESS might be larger than 0.99 and a tolerance of 0.01 would be problematic in those settings.
It might be good if it were possible to choose this tolerance without changing a hard-coded constant. In some applications the desired CESS might be larger than 0.99 and a tolerance of 0.01 would be problematic in those settings.
LeahPrice
Aug 7, 2017
Author
Collaborator
Thanks Adam for this and for all of your other good points. I should have picked up on at least some of these myself -- sorry about that. I've changed this and a couple of other minor things (like writing 1.0 instead of 1 if it's a double) and will do another commit when the check finishes.
Thanks Adam for this and for all of your other good points. I should have picked up on at least some of these myself -- sorry about that. I've changed this and a couple of other minor things (like writing 1.0 instead of 1 if it's a double) and will do another commit when the check finishes.
| /// \param desiredAcceptProb The desired probability of a successful move for each particle. | ||
| /// \param initialN The initial number of MCMC repeats. | ||
| /// \param maxReps The maximum number of MCMC repeats. | ||
| int staticModelAdapt::calcMcmcRepeats(double acceptProb, double desiredAcceptProb, int initialN, int maxReps){ |
adamjohansen
Aug 7, 2017
Collaborator
It's a bad idea to compare doubles with integers using ==, usually (the finite precision issue), might it make sense to replace these comparisons with
abs(acceptProb - 1) <= 10**-9
or similar?
It's a bad idea to compare doubles with integers using ==, usually (the finite precision issue), might it make sense to replace these comparisons with
abs(acceptProb - 1) <= 10**-9
or similar?
|
Great, thanks. |
Adding a class containing commonly used parameters and methods to adapt them (for static Bayesian models).