joshspeagle / dynesty

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

Different live point values in prior and likelihood function #156

Closed sharanbngr closed 5 years ago

sharanbngr commented 5 years ago

Hello @joshspeagle ,

I am seeing different values for the live points in the prior and likelihood functions in what should be a single sample of the parameter space. This has me confused and little concerned that this might bias the estimation of the evidence and parameter values.

I have tried different sampling methods (rwalk, auto, unif) and still see the same behavior. For example in one instance, I see the following sample values in the prior function (after reshaping the uniform cube)

(Pdb)theta
(-3.186324503978064, -12.467510335969395, -40.916755592651874, -47.66509354770035)

And then when the execution pauses in the likelihood method,

(Pdb) theta
array([ -2.91539463,  -8.81681062, -41.10269018, -50.29590999])

If this is a feature and intended behavior, could you please point me to the documentation or the piece of code which does this so that I can understand it better. Thank you!

joshspeagle commented 5 years ago

Could you show how you're querying this? I can confirm that the likelihood calls are indeed executed via:

u-> v = prior_transform(u) -> loglikelihood(v)

in almost all cases, and so there is a one-to-one correspondance between the position of the sample and the loglikelihood. If there's an error in the saved samples_u, that would be a major bug.

sharanbngr commented 5 years ago

Actually, I think what I was seeing was due to the fact that at the start of a run a bunch of live points are created before their likelihoods are calculated. So the live point I query in the prior was the last one (in the say 100 live points asked for), but the live point I was querying in the likelihood is the first one.

I just printed out all the live points in both the likelihood and the prior and the lists match.

Apologies about wasting your time with this (and any alarm this might have caused)!

joshspeagle commented 5 years ago

No problem -- glad this turned out to be benign :)