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 well with MCMC sampling techniques that naturally provide samples from multiple chains by their ensemble nature, such as affine invariant ensemble samplers. For instance, harmonic can be used with the popular emcee code implementing the affine invariant sampler of Goodman & Weare (2010), or the NumPyro code implementing various MCMC algorithms.
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 Polanska et al. (2024) if using normalizing flow models.
A BibTeX entry for the paper is:
@misc{polanska2024learned,
title={Learned harmonic mean estimation of the Bayesian evidence with normalizing flows},
author={Alicja Polanska and Matthew A. Price and Davide Piras and Alessio Spurio Mancini and Jason D. McEwen},
year={2024},
eprint={2405.05969},
archivePrefix={arXiv},
primaryClass={astro-ph.IM}
}
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}
}
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file harmonic-1.2.3.tar.gz
.
File metadata
- Download URL: harmonic-1.2.3.tar.gz
- Upload date:
- Size: 240.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e20d8bbb4ac16dffabceaeb486884d3bdfcebf42fcd07e15c0fd108b09f18541 |
|
MD5 | 5047b161e6d69895a64f11a05a4d6b88 |
|
BLAKE2b-256 | 466b55ecbd7fdf22c0a10b6d7a10653fd7b05c21d1021b8959acd7aa1443534e |
File details
Details for the file harmonic-1.2.3-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: harmonic-1.2.3-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 354.1 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e25207d3a939ae4a4bf5ac2f5bbe486df0471580de18b745f3da6ba56db49626 |
|
MD5 | 70427223b27f6ab2ecd272dffb25bd4b |
|
BLAKE2b-256 | 45cc1a5e5ec4709cb8824fcce03ba97a88eb72cdd9f86aabd62919489b0d8404 |
File details
Details for the file harmonic-1.2.3-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: harmonic-1.2.3-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 358.2 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7b978ca13bbbbfad7f21beae9ee916ed270c3a8a30333406a9c3eda31170a13 |
|
MD5 | 5fadf065d2d3e1aed5bc32fc7b87d1f6 |
|
BLAKE2b-256 | c6b3d8e933ca0752f3337172f5aa83c0a6f9e432d3fb8ba8f5ae1229f1dfc11e |
File details
Details for the file harmonic-1.2.3-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: harmonic-1.2.3-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 354.1 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fae25ca9202847fe3901189392cac71ed36065b0c7e663df24953d1576dbcfc |
|
MD5 | 3286c0b53160b7488f2bb076fdde7e60 |
|
BLAKE2b-256 | 46805a2398bbbd878536f57ce91874a9e9b73667b292222d01591244e979bda7 |