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 http://img.shields.io/badge/arXiv-2405.05969-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 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


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.3.1.tar.gz (2.1 MB view details)

Uploaded Source

Built Distributions

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

harmonic-1.3.1-cp313-cp313-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

harmonic-1.3.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

harmonic-1.3.1-cp313-cp313-macosx_11_0_arm64.whl (405.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

harmonic-1.3.1-cp312-cp312-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

harmonic-1.3.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

harmonic-1.3.1-cp312-cp312-macosx_11_0_arm64.whl (417.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

harmonic-1.3.1-cp311-cp311-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

harmonic-1.3.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

harmonic-1.3.1-cp311-cp311-macosx_11_0_arm64.whl (426.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: harmonic-1.3.1.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for harmonic-1.3.1.tar.gz
Algorithm Hash digest
SHA256 fdaaa37c7a1e1048beda6416eab6d5925e276c0bf74f742be5a7b2f9eaa4d560
MD5 f67ae2bfa1e7238f3c4e257aaec95bd3
BLAKE2b-256 207507f7014650a13b7947b11d4307a5c397ddb0b7da0ca9684ef1d5ddd44dcc

See more details on using hashes here.

Provenance

The following attestation bundles were made for harmonic-1.3.1.tar.gz:

Publisher: build.yml on astro-informatics/harmonic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file harmonic-1.3.1-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for harmonic-1.3.1-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 51eee58674b4083fef5f27eda276db1a0ceacfdfcde911a5d8adc09357db8d40
MD5 43c6a080ff45767255771f5d9fb5524c
BLAKE2b-256 fc23ef50c3a348fbf03127e726ad01cf334e67f67f06aadb5ae93ba7a6b25dc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for harmonic-1.3.1-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: build.yml on astro-informatics/harmonic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file harmonic-1.3.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for harmonic-1.3.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5e6b83655f9f4ba5b664835a65de3aee9b619ac5796dfcf59b21a7396a7454d1
MD5 861b4884c035ce4b7d001b231b58db88
BLAKE2b-256 2376295fc09816abea608d34f8a0d99435cdea48902c36d61db478bcf9692fa5

See more details on using hashes here.

Provenance

The following attestation bundles were made for harmonic-1.3.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: build.yml on astro-informatics/harmonic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file harmonic-1.3.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for harmonic-1.3.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d56a8bedd9d2650058af19cb5c2897cb32ad0016306d6da99c0dc86040f39c1f
MD5 3ea950b104045ef502d1b5f2d7f3c5ad
BLAKE2b-256 59e72986891c8cfcd465a5a72537042f377ec82c1e4dfb2a834fac8ac5b7e95a

See more details on using hashes here.

Provenance

The following attestation bundles were made for harmonic-1.3.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: build.yml on astro-informatics/harmonic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file harmonic-1.3.1-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for harmonic-1.3.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e86d004ee2a5d05374ad628d34d52ee9489b6d9dbf284d37d8e4f9a67888b162
MD5 0c9a91737e3305984e08328f7b1f13b9
BLAKE2b-256 964ba407e6a8bde4cfdc7f22678ad64603f1e6051f27fb663a5b17a19569e7bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for harmonic-1.3.1-cp312-cp312-musllinux_1_2_x86_64.whl:

Publisher: build.yml on astro-informatics/harmonic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file harmonic-1.3.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for harmonic-1.3.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 80086a7c24434e27c4358e3b9866609eb91bae1861f77ab9b858b6d33aeaea66
MD5 411356bc020714b73c4e5529669ff827
BLAKE2b-256 c5cc2a7211bc73c1f4223216b5782f46cf854b5b86277cee2bd96d3155dc0a7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for harmonic-1.3.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: build.yml on astro-informatics/harmonic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file harmonic-1.3.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for harmonic-1.3.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 baf629913d89e130b81afd18cfee798a6f9c5092532026fe175295a5a3c4c5e1
MD5 ed0de23b8a9a28c4185f1a00a57ac6f5
BLAKE2b-256 2c11b8c9698ab92e0da5ad9bad64c7c2d3c2121a3529ff5087660726744eb8ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for harmonic-1.3.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: build.yml on astro-informatics/harmonic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file harmonic-1.3.1-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for harmonic-1.3.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 04942551a8e02054f5966c415188eb69598dc0cbcadb8bf427507564abb96b1e
MD5 6bcda5939d733e29e7b8049f178d0e02
BLAKE2b-256 d77b09a66254b0504afb35ae550a3c405b64edb4f67bc2e7981c17d4a5cc2fff

See more details on using hashes here.

Provenance

The following attestation bundles were made for harmonic-1.3.1-cp311-cp311-musllinux_1_2_x86_64.whl:

Publisher: build.yml on astro-informatics/harmonic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file harmonic-1.3.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for harmonic-1.3.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 76683f8bfa2ac8060afb7fa2b71c3e3a952a71970c0b0f8a08fd186dd3cbcbcb
MD5 43b7d99b07eb73fc8195bf0ecf822b6c
BLAKE2b-256 917cc8947553944517d2f4673a97e77f8abd26ab6b20b00b5037ee723bf10de4

See more details on using hashes here.

Provenance

The following attestation bundles were made for harmonic-1.3.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: build.yml on astro-informatics/harmonic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file harmonic-1.3.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for harmonic-1.3.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 86984f79b8068ea0532dae52de7e7f0e517c92a57f1aa406c40f730f48dfe7df
MD5 33366ce8532c9cafd14ab17248d48a14
BLAKE2b-256 6afa791b9875f9ce5fe298cc81b7854071908c8b587ef1b7aa3f1b7e43ef44c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for harmonic-1.3.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: build.yml on astro-informatics/harmonic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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