Skip to main content

Python package for efficient Bayesian evidence computation

Project description

Python package to efficiently compute the learnt harmonic mean estimator of the Bayesian evidence

harmonic is an open source, well tested and documented Python implementation of the learnt harmonic mean estimator (McEwen et al. 2021) to compute the marginal likelihood (Bayesian evidence), required for Bayesian model selection.

While harmonic requires only posterior samples, and so is agnostic to the technique used to perform Markov chain Monte Carlo (MCMC) sampling, harmonic works exceptionally well with MCMC sampling techniques that naturally provide samples from multiple chains by their ensemble nature, such as affine invariant ensemble samplers. We therefore advocate use of harmonic with the popular emcee code implementing the affine invariant sampler of Goodman & Weare (2010).

Basic usage is highlighted in this interactive demo.


Comprehensive documentation for harmonic is available.


Please cite McEwen et al. (2021) if this code package has been of use in your project.

A BibTeX entry for the paper is:

   author = {Jason~D.~McEwen and Christopher~G.~R.~Wallis and Matthew~A.~Price and Matthew~M.~Docherty},
    title = {Machine learning assisted {B}ayesian model comparison: learnt harmonic mean estimator},
  journal = {ArXiv},
   eprint = {arXiv:2111.12720},
     year = 2021


harmonic is released under the GPL-3 license (see LICENSE.txt), subject to the non-commercial use condition (see LICENSE_EXT.txt)

Copyright (C) 2021 Jason D. McEwen, Christopher G. R. Wallis,
Matthew A. Price, Matthew M. Docherty & contributors

This program is released under the GPL-3 license (see LICENSE.txt),
subject to a non-commercial use condition (see LICENSE_EXT.txt).

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

harmonic-1.0.3.tar.gz (425.1 kB view hashes)

Uploaded Source

Built Distributions

harmonic-1.0.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.5+ x86-64

harmonic-1.0.3-cp38-cp38-macosx_10_9_x86_64.whl (410.7 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

harmonic-1.0.3-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.5+ x86-64

harmonic-1.0.3-cp37-cp37m-macosx_10_9_x86_64.whl (401.9 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

harmonic-1.0.3-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.5+ x86-64

harmonic-1.0.3-cp36-cp36m-macosx_10_9_x86_64.whl (422.4 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page