Skip to content

Resolve "Inconsistent saved `log_likelihood` values"

Colm Talbot requested to merge 182-inconsistent-saved-log_likelihood-values into master

Closes #182 (closed)

This fixes the ordering of the stored log likelihoods in dynesty and nestle.

This can be demonstrated by appending the following code to https://git.ligo.org/Monash/tupak/blob/master/examples/other_examples/gaussian_example.py

for ii in range(len(result.posterior)):
    if sum(result.posterior.mu.values == result.posterior.mu.values[ii]) > 1:
        break

if np.where(result.posterior.mu.values == result.posterior.mu.values[ii]) ==\
        np.where(result.posterior.log_likelihood.values == result.posterior.log_likelihood.values[ii]):
    print('Working')

This tests that the repeated values of mu in the posterior have equal log_likelihood.

Note that this duplication of posterior samples is due to nestle and dynesty creating as many nested samples as posterior samples.

One can instead downsample to generate the posterior and avoid duplication:

keep = result.nested_samples.weights.values  >\
    np.random.uniform(0, max(result.nested_samples.weights.values), len(result.posterior))
alternate_posterior = result.nested_samples.copy()[keep]
Edited by Colm Talbot

Merge request reports