joshspeagle / dynesty

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

merge_runs fails due to nlive not set and negative logzvar #186

Closed ahallcosmo closed 3 years ago

ahallcosmo commented 4 years ago

Hi,

I've encountered a couple of issues in the merge_runs function. Firstly it fails at the line

r.append(('logzerr', np.sqrt(np.array(combined_logzvar))))

since some values of my combined_logzvar are negative (presumably due to mis-estimation of the variance of logz).

Secondly, the merged results instance has not had its 'nlive' attribute set, so, e.g., results.summary() fails.

Cheers, Alex

joshspeagle commented 4 years ago

The first line

np.sqrt(np.array(combined_logzvar))

should throw warnings but still go through unless the default behavior in numpy has changed recently. The nan values are indeed expected and due to the approximation scheme used to estimate the variance. A more robust method for estimating the variance can be achieved through some of the functions in dynesty.utils as outlined in the docs.

The second issue

the merged results instance has not had its 'nlive' attribute set, so, e.g., results.summary() fails.

is indeed an actual bug that's been raised in #175 and #184. It should be a small fix but I just haven't gotten around to it yet.