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 upLog Ratio of Normalizing Constants #7
Conversation
Adding estimators of the log ratio of normalising constant based on - the standard SMC estimator - path sampling estimator with 1st and 2nd order trapezoidal integration
|
I moved the function Some of this is a little different to what I have in my master copy - I changed the template parameter for history to make it easier for users to write the path sampling integrands. I've checked that everything still works properly on the linear regression example but I'm saving that for a future pull request where I'll document it properly. Please let me know if you'd like me to add it in now. |
| /// normalising weights, calculating the effective sample size and estimating the normalising constant. | ||
| /// | ||
| /// \param logw The log weights of interest. | ||
| inline double stableLogSumWeights(const arma::vec & logw){ |
adamjohansen
Jul 27, 2017
Collaborator
I'm doing this too quickly, because I need to check out of my accommodation shortly, but is this "code in a header"? With the exception of /templated/ functions which are instructions to the compiler to generate code rather than code itself, or inline member functions, it's usual to keep only declarations in the header (to prevent the kind of compiler error that Dirk encountered) with the declaration living elsewhere in a source file.
I'm doing this too quickly, because I need to check out of my accommodation shortly, but is this "code in a header"? With the exception of /templated/ functions which are instructions to the compiler to generate code rather than code itself, or inline member functions, it's usual to keep only declarations in the header (to prevent the kind of compiler error that Dirk encountered) with the declaration living elsewhere in a source file.
LeahPrice
Jul 27, 2017
Author
Collaborator
Great, thank you. I've created a new source file to contain that and possible other general use function definitions (it didn't fit naturally under the current source files).
Great, thank you. I've created a new source file to contain that and possible other general use function definitions (it didn't fit naturally under the current source files).
|
|
||
| //Normalise the weights | ||
| pPopulation.SetLogWeight(pPopulation.GetLogWeight() - dlogNCIt*arma::ones(N)); |
adamjohansen
Jul 27, 2017
Collaborator
Do you actually need to create the vector of ones here (glancing at the Armadillo docs, isn't arma::vec - double well defined)? If you do need the extra vector, it might be sensible to have a static N-vector of ones available to avoid the overheads.
Do you actually need to create the vector of ones here (glancing at the Armadillo docs, isn't arma::vec - double well defined)? If you do need the extra vector, it might be sensible to have a static N-vector of ones available to avoid the overheads.
LeahPrice
Jul 27, 2017
Author
Collaborator
Good point, thanks.
Good point, thanks.
|
Thanks, @LeahPrice, I've made a couple of very small comments but this essentially looks good to me. |
and moving the stableLogSumWeights function definition to a source file.
|
Great, this looks good to me. (I just realised it might not have been obvious from my previous comment, but the reason to avoid introducing the vector of ones is just that it involves allocating N*sizeof(double) bytes of memory and then initializing it every time and N might be quite large.) |
Adding estimators of the log ratio of normalizing constant based on