Skip to main content

logo

pocoMC is a Python implementation of the Preconditioned Monte Carlo method for accelerated Bayesian inference

License: GPL v3 Documentation Status

Getting started

Brief introduction

pocoMC is a Python package for fast Bayesian posterior and model evidence estimation. It leverages the Preconditioned Monte Carlo (PMC) algorithm, offering significant speed improvements over traditional methods like MCMC and Nested Sampling. Ideal for large-scale scientific problems with expensive likelihood evaluations, non-linear correlations, and multimodality, pocoMC provides efficient and scalable posterior sampling and model evidence estimation. Widely used in cosmology and astronomy, pocoMC is user-friendly, flexible, and actively maintained.

Documentation

Read the docs at pocomc.readthedocs.io for more information, examples and tutorials.

Installation

To install pocomc using pip run:

pip install pocomc

or, to install from source:

git clone https://github.com/minaskar/pocomc.git
cd pocomc
python setup.py install

Basic example

For instance, if you wanted to draw samples from a 10-dimensional Rosenbrock distribution with a uniform prior, you would do something like:

import pocomc as pc
import numpy as np
from scipy.stats import uniform

n_dim = 10  # Number of dimensions

prior = pc.Prior(n_dim*[uniform(-10.0, 20.0)]) # U(-10,10)

def log_likelihood(x):
    return -np.sum(10.0*(x[:,::2]**2.0 - x[:,1::2])**2.0 \
            + (x[:,::2] - 1.0)**2.0, axis=1)

sampler = pc.Sampler(
    prior=prior,
    likelihood=log_likelihood,
    vectorize=True,
)
sampler.run()

samples, weights, logl, logp = sampler.posterior() # Weighted posterior samples

logz, logz_err = sampler.evidence() # Bayesian model evidence estimate and uncertainty

Attribution & Citation

Please cite the following papers if you found this code useful in your research:

@article{karamanis2022accelerating,
    title={Accelerating astronomical and cosmological inference with preconditioned Monte Carlo},
    author={Karamanis, Minas and Beutler, Florian and Peacock, John A and Nabergoj, David and Seljak, Uro{\v{s}}},
    journal={Monthly Notices of the Royal Astronomical Society},
    volume={516},
    number={2},
    pages={1644--1653},
    year={2022},
    publisher={Oxford University Press}
}

@article{karamanis2022pocomc,
    title={pocoMC: A Python package for accelerated Bayesian inference in astronomy and cosmology},
    author={Karamanis, Minas and Nabergoj, David and Beutler, Florian and Peacock, John A and Seljak, Uros},
    journal={arXiv preprint arXiv:2207.05660},
    year={2022}
}

Licence

Copyright 2022-Now Minas Karamanis and contributors.

pocoMC is free software made available under the GPL-3.0 License. For details see the LICENSE file.

Metadata

Release files for pocomc 1.2.6

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

Source distribution (sdist)

Source distribution for pocomc 1.2.6
File Size Uploaded Provenance Actions
pocomc-1.2.6.tar.gz 46.3 kB Without provenance Details for pocomc-1.2.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pocomc 1.2.6
File Interpreter ABI Platform Actions
pocomc-1.2.6-py3-none-any.whl Python 3 none any Details for pocomc-1.2.6-py3-none-any.whl

Total release size: 92.3 kB

Release files / pocomc-1.2.6.tar.gz

Download URL pocomc-1.2.6.tar.gz
Size 46.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c9d28250b379ccd80eee043c1d1b6fbfb68e4fe07cf848f5a8b0af9c42052b31
BLAKE2b-256 checksum
How to use checksums
1391b5118f38e75d0a6ef6f6736db1bf1f7af4e84a8f43cb728e15451b92f158
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / pocomc-1.2.6-py3-none-any.whl

Download URL pocomc-1.2.6-py3-none-any.whl
Size 46.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd087841d27cce0a0940697cd4ff95456dc15400d680db8fb82b133fa9945bd7
BLAKE2b-256 checksum
How to use checksums
db439bcde0d06aefc46856af85e8c495e9026f3374af0e95a0bb396ef8f8c119
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Security for pocomc 1.2.6

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2.6 This release

2 release files No provenance

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