Inconsistent saved likelihood values when using "emcee" sampler
In the stage of saving samples using "emcee" sampler, in this line, sampler.blobs
have the shape of (nsamples, nwalkers, 2)
, where 2
means len([log_likelihood, log_prior])
. After reshaping process blobs[self.nburn :, :, :].reshape((-1, 2))
, log_likelihoods, log_priors
will list the values in the way like value of the first iteration of every walker, and then value of the second iteration of each walkers, etc. However, in this line, sampler.chain
store the values of parameter samples in shape of (nwalkers, nsamples, len(parameters))
(note the difference from blobs above). After reshaping process self.sampler.chain[:, self.nburn :, :].reshape((-1, self.ndim))
, samples will list the values in the way like value of every iteration of first walkers, and then value of every iteration of second walkers, etc. The storage order of parameter sample values does not correspond to the order of log_likelihood values in this way.
Using the simple "linear regression" example in bilby compare_sampler tutorial, running the 'emcee' sampler only, even for the samples with the same parameter values, the log_likelihood values do not agree with each other.
But the total number of samples with the same parameter values is consistent with the total number of samples with the same log_likelihood values.
If it is the case, I think the resolution here is to re-define a proper reshaping way for either sampler.blobs
or sampler.chain