joshspeagle / dynesty

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

Stopping criterion not working #155

Closed RiccardoBuscicchio closed 5 years ago

RiccardoBuscicchio commented 5 years ago

I've been running a few times with dynesty without problems. However, when setting live_points manually, even if the stopping criterion is satisfied, the run doesn't stop. [EDIT: the run did actually stop, but long after the threshold criterion was satisfied] Here is the call signature:

work = dynesty.NestedSampler(loglikelihood=loglike_wrap,
                                     prior_transform=ptransform,
                                     ndim=24,
                                     sample='auto',
                                     bound='multi',
                                     nlive=4096,
                                     live_points=[start['u'], start['v'], start['logl']],
                                     pool=Pool(processes=16),
                                     queue_size=16)
sys.stdout.write("Defined the worker. Running it now..\n")
work.run_nested(dlogz=0.1)

and here is the run output at the threshold crossing..

iter: 194105 | bound: 492 | nc: 748 | ncall: 143150621 | eff(%):  0.136 | loglstar:   -inf < -46.827 <    inf | logz: -87.156 +/-  0.111 | dlogz:  0.101 >  0.100                
iter: 194106 | bound: 492 | nc: 866 | ncall: 143151487 | eff(%):  0.136 | loglstar:   -inf < -46.827 <    inf | logz: -87.156 +/-  0.111 | dlogz:  0.100 >  0.100

and at its current status...

iter: 194126 | +4077 | bound: 492 | nc: 1 | ncall: 143165698 | eff(%):  0.138 | loglstar:   -inf < -43.900 <    inf | logz: -87.154 +/-  0.112 | dlogz:  0.001 >  0.100
iter: 194126 | +4078 | bound: 492 | nc: 1 | ncall: 143165698 | eff(%):  0.138 | loglstar:   -inf < -43.890 <    inf | logz: -87.154 +/-  0.112 | dlogz:  0.000 >  0.100

is there anything specific I can do to help diagnosing the problem?

joshspeagle commented 5 years ago

Wait, but it actually is done, at least according to the output. The +X indicates it’s just adding the final set of live points to the results after terminating at iteration 194126 (which only requires a single function call). Is that not happening properly? How many live points did you specify when starting?

RiccardoBuscicchio commented 5 years ago

Thanks for the prompt reply, @joshspeagle . And yes, you are right. I just noticed that the last nlive lines (4096 in my case) were "over" the threshold: their dlogz 0.0XYZ > 0.100 were a little misleading. I guess once the threshold is reached the inequality is irrelevant, dlogz being the amount of evidence coming from the remaining points in the final set.

joshspeagle commented 5 years ago

Exactly. I have this enabled by default since the samples are effectively free (you’ve already proposed the points, so why not use them), but you can also disable it if you want to maintain the hard dlogz boundary.