Skip to content

Alternative method for calculating reflective bound adjustment

This commit changes how proposals are adjusted to fall within the prior bounds when the variable is linear, rather than circular. Instead of literally reflecting back and forth, which can require many iterations if the proposed value is far outside of the allowed range, the correct adjustment is now calculated by finding the remainder when the excess of the proposed value from the nearest bound is divided by that range. This is similar to how circular variables are handled, except now we must track whether the range divides the excess an even or odd number of times.

An example of "worst-case" behavior before this patch can be seen in the profile results here. The rank zero profile shows the job spending essentially all of its time in the LALInferenceCyclicReflectiveBound function, while the results for the other three ranks spend all of their time waiting on rank zero. This behavior doesn't consistently occur; I don't know, but suspect it happens in the early stages of an adaptive gaussian proposal, if the proposed value of a linear parameter is so far outside of the prior bounds that it takes a huge number of reflections to bring it back within range. I suppose this could also happen for multiple parameters, or repeatedly for the same parameter (I don't know the interplay between this parameter adjustment and the accept/reject stage of the MC---if it's rejected, is it the adjusted value that's kept, or does it go back to the unadjusted value?)

An example of the output from running the lalinference testjob script before this change is here; after the change, with the same parameters, here. The results are not identical, though to my eye they seem close, but I'm not experienced enough to know what is a "reasonable" variation in results just from a slightly different walk. Since the brute force method that this PR replaces would be highly numerically unstable if many reflections are required, it's possible that they don't agree exactly. But if the degree of difference is concerning, or you would like to see other tests, please let me know.

Merge request reports