Skip to main content

Python package for efficient Bayesian evidence computation

Project description

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.

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.2.0.tar.gz (203.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

harmonic-1.2.0-cp310-cp310-macosx_11_0_arm64.whl (159.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

harmonic-1.2.0-cp39-cp39-macosx_11_0_arm64.whl (161.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

harmonic-1.2.0-cp38-cp38-macosx_11_0_arm64.whl (160.2 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

Details for the file harmonic-1.2.0.tar.gz.

File metadata

  • Download URL: harmonic-1.2.0.tar.gz
  • Upload date:
  • Size: 203.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for harmonic-1.2.0.tar.gz
Algorithm Hash digest
SHA256 98f40dbfec3ff5546623f48566f3e58b15299ca13d0293e84e769982917ca2fa
MD5 370940eef1c5ac31cab095cd66e2cf9e
BLAKE2b-256 14673747d130c3edc94033f484ebeb4558a2fde41fc4ceaee9b2636bb5025554

See more details on using hashes here.

File details

Details for the file harmonic-1.2.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for harmonic-1.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3a6faacb409f820e532ca8fc1a6a11cb6ec7ef254f54c1cb02654ea23aa6e8d4
MD5 9ab6f17021d3821837741cb7bf232779
BLAKE2b-256 8a080819198960d72b39366b572f223cbb01c62f59ae1a7cce3daa57f485ca57

See more details on using hashes here.

File details

Details for the file harmonic-1.2.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for harmonic-1.2.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 46aa74c4045b1feba265bad3c42f04f77cb0c04f7de6669654eed116a0fad96a
MD5 e38c9656decae89e00543a29b681d4f2
BLAKE2b-256 c7a769729cc68046b7edcf2c5c025ab02ef80e7050a9b170a81c2f3a33395c1b

See more details on using hashes here.

File details

Details for the file harmonic-1.2.0-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for harmonic-1.2.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6d4974bc3621f025dffe485033d4091cd1d996e8f34da2ba08a55fd31843e516
MD5 44b81a9d493991f6b2a31b2838b73ebd
BLAKE2b-256 3b43366619f32b091fbe9e5e23ab99bb88b480c3b409a4e79394206cd2b41ac9

See more details on using hashes here.

Supported by

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