Skip to main content

harmonic

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.

Metadata

Release files for harmonic 1.3.1

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.3.1
File Size Uploaded
harmonic-1.3.1.tar.gz 2.1 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for harmonic 1.3.1
File
harmonic-1.3.1-cp313-cp313-musllinux_1_2_x86_64.whl CPython 3.13 CPython 3.13 Linux musl 1.2+ x86-64 Details
harmonic-1.3.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details
harmonic-1.3.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
harmonic-1.3.1-cp312-cp312-musllinux_1_2_x86_64.whl CPython 3.12 CPython 3.12 Linux musl 1.2+ x86-64 Details
harmonic-1.3.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details
harmonic-1.3.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
harmonic-1.3.1-cp311-cp311-musllinux_1_2_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.2+ x86-64 Details
harmonic-1.3.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.5+ x86-64 Details
harmonic-1.3.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details

Total release size: 11.1 MB

Release files / harmonic-1.3.1.tar.gz

Download URL harmonic-1.3.1.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
fdaaa37c7a1e1048beda6416eab6d5925e276c0bf74f742be5a7b2f9eaa4d560
BLAKE2b-256 checksum
How to use checksums
207507f7014650a13b7947b11d4307a5c397ddb0b7da0ca9684ef1d5ddd44dcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release files / harmonic-1.3.1-cp313-cp313-musllinux_1_2_x86_64.whl

Download URL harmonic-1.3.1-cp313-cp313-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.13 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
51eee58674b4083fef5f27eda276db1a0ceacfdfcde911a5d8adc09357db8d40
BLAKE2b-256 checksum
How to use checksums
fc23ef50c3a348fbf03127e726ad01cf334e67f67f06aadb5ae93ba7a6b25dc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release files / harmonic-1.3.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL harmonic-1.3.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 1.3 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
5e6b83655f9f4ba5b664835a65de3aee9b619ac5796dfcf59b21a7396a7454d1
BLAKE2b-256 checksum
How to use checksums
2376295fc09816abea608d34f8a0d99435cdea48902c36d61db478bcf9692fa5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release files / harmonic-1.3.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL harmonic-1.3.1-cp313-cp313-macosx_11_0_arm64.whl
Size 405.3 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d56a8bedd9d2650058af19cb5c2897cb32ad0016306d6da99c0dc86040f39c1f
BLAKE2b-256 checksum
How to use checksums
59e72986891c8cfcd465a5a72537042f377ec82c1e4dfb2a834fac8ac5b7e95a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release files / harmonic-1.3.1-cp312-cp312-musllinux_1_2_x86_64.whl

Download URL harmonic-1.3.1-cp312-cp312-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
e86d004ee2a5d05374ad628d34d52ee9489b6d9dbf284d37d8e4f9a67888b162
BLAKE2b-256 checksum
How to use checksums
964ba407e6a8bde4cfdc7f22678ad64603f1e6051f27fb663a5b17a19569e7bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release files / harmonic-1.3.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL harmonic-1.3.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 1.3 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
80086a7c24434e27c4358e3b9866609eb91bae1861f77ab9b858b6d33aeaea66
BLAKE2b-256 checksum
How to use checksums
c5cc2a7211bc73c1f4223216b5782f46cf854b5b86277cee2bd96d3155dc0a7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release files / harmonic-1.3.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL harmonic-1.3.1-cp312-cp312-macosx_11_0_arm64.whl
Size 417.9 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
baf629913d89e130b81afd18cfee798a6f9c5092532026fe175295a5a3c4c5e1
BLAKE2b-256 checksum
How to use checksums
2c11b8c9698ab92e0da5ad9bad64c7c2d3c2121a3529ff5087660726744eb8ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release files / harmonic-1.3.1-cp311-cp311-musllinux_1_2_x86_64.whl

Download URL harmonic-1.3.1-cp311-cp311-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
04942551a8e02054f5966c415188eb69598dc0cbcadb8bf427507564abb96b1e
BLAKE2b-256 checksum
How to use checksums
d77b09a66254b0504afb35ae550a3c405b64edb4f67bc2e7981c17d4a5cc2fff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release files / harmonic-1.3.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL harmonic-1.3.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 1.3 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
76683f8bfa2ac8060afb7fa2b71c3e3a952a71970c0b0f8a08fd186dd3cbcbcb
BLAKE2b-256 checksum
How to use checksums
917cc8947553944517d2f4673a97e77f8abd26ab6b20b00b5037ee723bf10de4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

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

Download URL harmonic-1.3.1-cp311-cp311-macosx_11_0_arm64.whl
Size 426.1 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
86984f79b8068ea0532dae52de7e7f0e517c92a57f1aa406c40f730f48dfe7df
BLAKE2b-256 checksum
How to use checksums
6afa791b9875f9ce5fe298cc81b7854071908c8b587ef1b7aa3f1b7e43ef44c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.3.1 This release

10 release files

1.3.0

2 release files

1.2.3

4 release files

1.2.2

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