Skip to main content
https://img.shields.io/badge/GitHub-harmonic-brightgreen.svg?style=flat https://github.com/astro-informatics/harmonic/actions/workflows/python.yml/badge.svg https://readthedocs.org/projects/ansicolortags/badge/?version=latest https://codecov.io/gh/astro-informatics/harmonic/branch/main/graph/badge.svg?token=1s4SATphHV https://img.shields.io/badge/License-GPL-blue.svg http://img.shields.io/badge/arXiv-2111.12720-orange.svg?style=flat http://img.shields.io/badge/arXiv-2207.04037-red.svg?style=flat http://img.shields.io/badge/arXiv-2307.00048-red.svg?style=flat

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.

Documentation

Comprehensive documentation for harmonic is available.

Attribution

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

A BibTeX entry for the paper is:

@article{harmonic,
   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
}

Please also cite Spurio Mancini et al. (2022) if this code has been of use in a simulation-based inference project.

A BibTeX entry for the paper is:

@article{spurio-mancini:harmonic_sbi,
   author   = {A.~Spurio Mancini and M.~M.~Docherty and M.~A.~Price and J.~D.~McEwen},
   doi      = {10.1093/rasti/rzad051},
   eprint   = {arXiv:2207.04037},
   journal  = {{RASTI}, in press},
   title    = {{B}ayesian model comparison for simulation-based inference},
   year     = {2023}
}
@inproceedings{polanska:harmonic_nfs_maxent,
   author    = {A.~Polanska and M.~A.~Price and A.~Spurio Mancini and J.~D.~McEwen},
   booktitle = {International Workshop on Bayesian Inference and Maximum Entropy Methods in Science and Engineering},
   eprint    = {arXiv:2307.00048},
   title     = {Learned harmonic mean estimation of the marginal likelihood with normalizing flows},
   year      = {2023}
}

License

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

harmonic
Copyright (C) 2021 Jason D. McEwen, Christopher G. R. Wallis,
Matthew A. Price, Matthew M. Docherty, Alessio Spurio Mancini,
Alicja Polanska & 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
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Release files for harmonic 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for harmonic 1.2.2
File Size Uploaded
harmonic-1.2.2.tar.gz 203.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for harmonic 1.2.2
File Interpreter ABI Platform
harmonic-1.2.2-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
harmonic-1.2.2-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
harmonic-1.2.2-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details

Total release size: 695.9 kB

Release files / harmonic-1.2.2.tar.gz

Download URL harmonic-1.2.2.tar.gz
Size 203.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e91f55f572ad517719eaf4f94c34d770c938760a043b948986c07d7a4d3b9089
BLAKE2b-256 checksum
How to use checksums
892f393c5b0a8760e00470c6b7f26e838332fa389db6dbf7f561c694b1e5f61f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.0

Release files / harmonic-1.2.2-cp311-cp311-macosx_11_0_arm64.whl

Download URL harmonic-1.2.2-cp311-cp311-macosx_11_0_arm64.whl
Size 159.7 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f820452a7222d0a33cf1a48898e056de95b6350e0e7d943e2831955e2ba69a74
BLAKE2b-256 checksum
How to use checksums
7cf0392740f41d2f7f34430d2d512ac858c2391ae3084cd67514914210a39181
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.0

Release files / harmonic-1.2.2-cp310-cp310-macosx_11_0_arm64.whl

Download URL harmonic-1.2.2-cp310-cp310-macosx_11_0_arm64.whl
Size 171.0 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9d8b0b135f85781e84a5545b0fb60208d1d6e22c7d547f7afb5a26d5da958543
BLAKE2b-256 checksum
How to use checksums
5b7c66f5ca008f43800f77c163f0fd691c2358ad792011d95ae5f649135753c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.0

Release files / harmonic-1.2.2-cp39-cp39-macosx_11_0_arm64.whl

Download URL harmonic-1.2.2-cp39-cp39-macosx_11_0_arm64.whl
Size 161.5 kB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f2e6362b0f11af97e4f5c78572ff2bffd73a5abdab1598d4e13e47f84d962e2e
BLAKE2b-256 checksum
How to use checksums
4ca261e219d00294dbf9e7837bd57a459d577c7c14ed0a22e0847ddbb63851ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.0

Release history Release notifications | RSS feed

1.3.1

10 release files

1.3.0

2 release files

1.2.3

4 release files

This release

1.2.2 This release

4 release files

1.2.1

4 release files

1.2.0

4 release files

1.1.1

7 release files

1.1.0

7 release files

1.0.3

7 release files

1.0.2

7 release files

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page