Skip to content

Commit

Permalink
minor numpy2 tidy; doc for gaussian_mixture names
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbant committed Dec 16, 2024
1 parent 7be6a20 commit 5c605d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cobaya/samplers/mcmc/mcmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,9 @@ def check_convergence_and_learn_proposal(self):
self.log.info(" - Average thinned weight: %.3f%s", 1 / acceptance_rate,
weights_multi_str)
else:
accpt_multi_str = (" = avg(%r)" % acceptance_rates.tolist()
if acceptance_rates is not None else "")
accpt_multi_str = (
" = avg([%s])" % ", ".join("%.4f" % x for x in acceptance_rates)
if acceptance_rates is not None else "")
self.log.info(" - Acceptance rate: %.3f%s", acceptance_rate,
accpt_multi_str)
self.progress.at[self.i_learn, "acceptance_rate"] = acceptance_rate
Expand Down Expand Up @@ -813,8 +814,8 @@ def check_convergence_and_learn_proposal(self):
self.log.debug(" - normalized std's of bounds = %r", Rminus1_cl)
Rminus1_cl = np.max(Rminus1_cl)
self.progress.at[self.i_learn, "Rminus1_cl"] = Rminus1_cl
accpt_multi_str = \
" = sum(%r)" % list(Ns) if more_than_one_process() else ""
accpt_multi_str = " = sum(%r)" % Ns.astype(int).tolist() \
if more_than_one_process() else ""
self.log.info(
" - Convergence of bounds: R-1 = %f after %d accepted steps%s",
Rminus1_cl,
Expand Down
12 changes: 12 additions & 0 deletions docs/likelihood_gaussian_mixture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ A delay (in seconds) in the likelihood evaluation can be specified with the keyw

This module also provides functions to generate random means and covariances – see automatic documentation below.

.. note::
If you want to use a Gaussian likelihood with particular input names, you can specify them explicitly, e.g.::

likelihood:
gaussian_mixture:
means: [[1.04103e-2, 0.02223, 0.1192]]
covs: [[6.8552146e-16, 1.4486860e-12, -1.4105674e-11],
[1.4486860e-12, 2.1344167e-08, -1.1534501e-07],
[-1.4105674e-11, -1.1534501e-07, 1.6977630e-06]]
input_params: ['thetastar', 'ombh2', 'omch2']
output_params: []

The default option values for this likelihood are

.. literalinclude:: ../cobaya/likelihoods/gaussian_mixture/gaussian_mixture.yaml
Expand Down

0 comments on commit 5c605d3

Please sign in to comment.