joshspeagle / dynesty

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

ValueError: low >= high #182

Closed joshjchayes closed 4 years ago

joshjchayes commented 4 years ago

Hi

I'm running dynesty v1.0.2 and have encountered the following error when running using the 'rslice' method

26808it [59:54,  7.46it/s, bound: 1559 | nc: 24 | ncall: 869519 | eff(%):  3.083 | loglstar:   -inf <   -inf <    inf | logz:   -inf +/- 20.220 | dlogz: 2029.594 >  0.069]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-cf1ff231b0ec> in <module>()
----> 1 r = test('all', 'single', 'rslice')

~/Dropbox/PhD/WASP-104/BJDs/advanced_retriever_tests.py in test(split_mode, ld_method, sample)
     44
     45
---> 46     results = retriever.run_retrieval(ld_fit_method=ld_method, fitting_mode=split_mode, nlive=60, sample=sample)
     47
     48     return results

~/anaconda3/lib/python3.6/site-packages/transitfit-0.10.0-py3.6.egg/transitfit/advanced_retriever.py in run_retrieval(self, ld_fit_method, fitting_mode, max_parameters, maxiter, maxcall, sample, nlive, dlogz, plot_final, plot_partial, results_output_folder, final_lightcurve_folder, plot_folder, plot_color, normalise, detrend)
    171             results, ndof = self._run_dynesty(self.all_lightcurves, priors,
    172                                               maxiter, maxcall, sample, nlive,
--> 173                                               dlogz)
    174
    175             # Print results to terminal

~/anaconda3/lib/python3.6/site-packages/transitfit-0.10.0-py3.6.egg/transitfit/advanced_retriever.py in _run_dynesty(self, lightcurves, priors, maxiter, maxcall, sample, nlive, dlogz)
    475         print(priors.fitting_params)
    476
--> 477         sampler.run_nested(maxiter=maxiter, maxcall=maxcall, dlogz=dlogz)
    478
    479         # Pull out the results and calculate a few additional bits of info

~/anaconda3/lib/python3.6/site-packages/dynesty-1.0.2-py3.6.egg/dynesty/sampler.py in run_nested(self, maxiter, maxcall, dlogz, logl_max, n_effective, add_live, print_progress, print_func, save_bounds)
    926                                                      save_samples=True,
    927                                                      n_effective=n_effective,
--> 928                                                      add_live=add_live)):
    929                 (worst, ustar, vstar, loglstar, logvol, logwt,
    930                  logz, logzvar, h, nc, worst_it, boundidx, bounditer,

~/anaconda3/lib/python3.6/site-packages/dynesty-1.0.2-py3.6.egg/dynesty/sampler.py in sample(self, maxiter, maxcall, dlogz, logl_max, n_effective, add_live, save_bounds, save_samples)
    780             # `logl > loglstar` using the bounding distribution and sampling
    781             # method from our sampler.
--> 782             u, v, logl, nc = self._new_point(loglstar_new, logvol)
    783             ncall += nc
    784             self.ncall += nc

~/anaconda3/lib/python3.6/site-packages/dynesty-1.0.2-py3.6.egg/dynesty/sampler.py in _new_point(self, loglstar, logvol)
    378         while True:
    379             # Get the next point from the queue
--> 380             u, v, logl, nc, blob = self._get_point_value(loglstar)
    381             ncall += nc
    382

~/anaconda3/lib/python3.6/site-packages/dynesty-1.0.2-py3.6.egg/dynesty/sampler.py in _get_point_value(self, loglstar)
    362         # If the queue is empty, refill it.
    363         if self.nqueue <= 0:
--> 364             self._fill_queue(loglstar)
    365
    366         # Grab the earliest entry.

~/anaconda3/lib/python3.6/site-packages/dynesty-1.0.2-py3.6.egg/dynesty/sampler.py in _fill_queue(self, loglstar)
    331             if self._beyond_unit_bound(loglstar):
    332                 # Propose points using the provided sampling/bounding options.
--> 333                 point, axes = self.propose_point()
    334                 evolve_point = self.evolve_point
    335             else:

~/anaconda3/lib/python3.6/site-packages/dynesty-1.0.2-py3.6.egg/dynesty/nestedsamplers.py in propose_live(self)
    664
    665         # Pick a random ellipsoid that encompasses `u`.
--> 666         ell_idx = ell_idxs[self.rstate.randint(nidx)]
    667
    668         # Choose axes.

mtrand.pyx in mtrand.RandomState.randint()

ValueError: low >= high

Is this a known issue, and how can I get around it? I have run this twice now and both times have raised the same error, but the first one raised it after around 4000 iterations.

Many thanks

joshspeagle commented 4 years ago

I think this is the same issue raised in #178. Most likely this is the ellipsoid decomposition failing. I would check the status of the output bounding objects prior to failure (assuming you have the sampler in memory) to see how they look. The easiest solution is to reparameterize the problem or change the priors to prevent this type of behavior. I need to add in a small warning message about this but haven't had the time to get around to it yet.