joshspeagle / dynesty

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

Ellipsoid check failed #461

Closed akashgpt closed 9 months ago

akashgpt commented 9 months ago

Dynesty version 2.1.1

Describe the bug I am getting an unfamiliar error: Ellipsoid check failed q=0, 401.82077270563605 What is this about?

Setup I am running the following dynesty setup: dsampler = dynesty.DynamicNestedSampler(loglike, prior_transform, ndim,nlive=10000)

Dynesty output

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
[/tmp/ipykernel_1648398/1784759571.py](https://file+.vscode-resource.vscode-cdn.net/tmp/ipykernel_1648398/1784759571.py) in <module>
      3 ################################################
      4 dsampler = dynesty.DynamicNestedSampler(loglike, prior_transform, ndim,nlive=10000)#, pool=pool, queue_size=10)
----> 5 dsampler.run_nested(wt_kwargs={'pfrac': 1.0})
      6 dres_f = dsampler.results
      7 ################################################

[~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/dynamicsampler.py](https://file+.vscode-resource.vscode-cdn.net/home/XYZ/~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/dynamicsampler.py) in run_nested(self, nlive_init, maxiter_init, maxcall_init, dlogz_init, logl_max_init, n_effective_init, nlive_batch, wt_function, wt_kwargs, maxiter_batch, maxcall_batch, maxiter, maxcall, maxbatch, n_effective, stop_function, stop_kwargs, use_stop, save_bounds, print_progress, print_func, live_points, resume, checkpoint_file, checkpoint_every)
   2038         try:
   2039             if not self.base:
-> 2040                 for results in self.sample_initial(
   2041                         nlive=nlive_init,
   2042                         dlogz=dlogz_init,

[~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/dynamicsampler.py](https://file+.vscode-resource.vscode-cdn.net/home/XYZ/~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/dynamicsampler.py) in sample_initial(self, nlive, update_interval, first_update, maxiter, maxcall, logl_max, dlogz, n_effective, live_points, save_samples, resume)
   1326             self.internal_state = DynamicSamplerStatesEnum.LIVEPOINTSINIT
   1327             # Run the sampler internally as a generator.
-> 1328         for it, results in enumerate(
   1329                 self.sampler.sample(maxiter=maxiter,
   1330                                     save_samples=save_samples,

[~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/sampler.py](https://file+.vscode-resource.vscode-cdn.net/home/XYZ/~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/sampler.py) in sample(self, maxiter, maxcall, dlogz, logl_max, n_effective, add_live, save_bounds, save_samples, resume)
    839             # `logl > loglstar` using the bounding distribution and sampling
    840             # method from our sampler.
--> 841             u, v, logl, nc = self._new_point(loglstar_new)
    842             ncall += nc
    843             self.ncall += nc

[~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/sampler.py](https://file+.vscode-resource.vscode-cdn.net/home/XYZ/~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/sampler.py) in _new_point(self, loglstar)
    419         while True:
    420             # Get the next point from the queue
--> 421             u, v, logl, nc, blob = self._get_point_value(loglstar)
    422             ncall += nc
    423             ncall_accum += nc

[~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/sampler.py](https://file+.vscode-resource.vscode-cdn.net/home/akashgpt/akashgpt/Academics/Research/VASP/analysis_codes/~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/sampler.py) in _get_point_value(self, loglstar)
    402         # If the queue is empty, refill it.
    403         if self.nqueue <= 0:
--> 404             self._fill_queue(loglstar)
    405 
    406         # Grab the earliest entry.

[~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/sampler.py](https://file+.vscode-resource.vscode-cdn.net/home/XYZ/~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/sampler.py) in _fill_queue(self, loglstar)
    359             evolve_point = self.evolve_point
    360             while self.nqueue < self.queue_size:
--> 361                 point, axes = self.propose_point(*args)
    362                 point_queue.append(point)
    363                 axes_queue.append(axes)

[~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/nestedsamplers.py](https://file+.vscode-resource.vscode-cdn.net/home/XYZ/~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/nestedsamplers.py) in propose_unif(self, *args)
    705             # Returns the point `u`, ellipsoid index `idx`, and number of
    706             # overlapping ellipsoids `q` at position `u`.
--> 707             u, idx = self.mell.sample(rstate=self.rstate)
    708             niter += 1
    709             # Check if the point is within the unit cube.

[~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/bounding.py](https://file+.vscode-resource.vscode-cdn.net/home/XYZ/~/anaconda3/lib/python3.8/site-packages/dynesty-2.1.1-py3.8.egg/dynesty/bounding.py) in sample(self, rstate, return_q)
    474                 if q == 0:
    475                     max_mask = ell_masks.max()
--> 476                     raise RuntimeError(
    477                         f'Ellipsoid check failed q=0, {max_mask}')
    478             if return_q:

RuntimeError: Ellipsoid check failed q=0, 401.82077270563605

Thank you!

segasai commented 9 months ago

Could you try 2.1.3 please, I fixed an issue like that earlier: https://github.com/joshspeagle/dynesty/blob/master/CHANGELOG.md#213---2023-10-04

akashgpt commented 9 months ago

Thank you! That indeed fixed it -- the run went smoothly.