joshspeagle / dynesty

Dynamic Nested Sampling package for computing Bayesian posteriors and evidences
https://dynesty.readthedocs.io/
MIT License
357 stars 77 forks source link

Periodic and reflecting boundaries #128

Closed GregoryAshton closed 5 years ago

GregoryAshton commented 5 years ago

The periodic boundaries introduced recently are great. For transient gravitational waves signals, the posteriors often are of the same size as the prior for parameters we don't measure well and this really helps.

Something we noticed though is that the current implementation doesn't work so well when the posteriors are "larger" than the prior. E.g, if you have a phase parameter which has a posterior width > 2 * pi.

Because dynesty doesn't update the position of the parameter, the parameters tend to wander until they hit the -0.5 and 1.5 boundaries (e.g. here) and then strange things happen. It would be a great improvement if there was some way to pass back into dynesty where they should be mapped to. That is, if dynesty proposes the point 1.1, but this should be mapped back to 0.1, then the u vector should be updated. This would prevent the issue.

Additionally, for parameters that are not periodic, dynesty currently struggles to sample near to the boundaries. This could be solved by implementing reflecting boundaries where 1.1 would be reflected to 0.9. From our perspective, any non-periodic parameter should be reflective by definition, but perhaps there are cases where this isn't true.

What are you thoughts on this? We plan to start trying to look into the internals and figure out how this could be implemented ourselves and perhaps create an MR. But, your input would be quite valuable to make sure we understand how best to do this.