pocomc


Namepocomc JSON
Version 1.2.5 PyPI version JSON
download
home_pagehttps://github.com/minaskar/pocomc
SummaryPreconditioned Monte Carlo
upload_time2024-09-16 17:32:52
maintainerNone
docs_urlNone
authorMinas Karamanis
requires_python>=3.8
licenseGPLv3
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![logo](logo.png)

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

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/minaskar/pocomc/blob/master/LICENSE)
[![Documentation Status](https://readthedocs.org/projects/pocomc/badge/?version=latest)](https://pocomc.readthedocs.io/en/latest/?badge=latest)


# 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](https://pocomc.readthedocs.io) for more information, examples and tutorials.

## Installation

To install ``pocomc`` using ``pip`` run:

```bash
pip install pocomc
```

or, to install from source:

```bash
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:

```python
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:

```bash
@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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/minaskar/pocomc",
    "name": "pocomc",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Minas Karamanis",
    "author_email": "minaskar@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/5c/98/9e73520ba620d594fc3db0209ef93708296af697ef5b2356259efea3ce17/pocomc-1.2.5.tar.gz",
    "platform": "any",
    "description": "![logo](logo.png)\n\n**pocoMC is a Python implementation of the Preconditioned Monte Carlo method for accelerated Bayesian inference**\n\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/minaskar/pocomc/blob/master/LICENSE)\n[![Documentation Status](https://readthedocs.org/projects/pocomc/badge/?version=latest)](https://pocomc.readthedocs.io/en/latest/?badge=latest)\n\n\n# Getting started\n\n## Brief introduction\n\n``pocoMC`` is a Python package for fast Bayesian posterior and model evidence estimation. It leverages \nthe Preconditioned Monte Carlo (PMC) algorithm, offering significant speed improvements over \ntraditional methods like MCMC and Nested Sampling. Ideal for large-scale scientific problems \nwith expensive likelihood evaluations, non-linear correlations, and multimodality, ``pocoMC`` \nprovides efficient and scalable posterior sampling and model evidence estimation. Widely used \nin cosmology and astronomy, ``pocoMC`` is user-friendly, flexible, and actively maintained.\n\n## Documentation\n\nRead the docs at [pocomc.readthedocs.io](https://pocomc.readthedocs.io) for more information, examples and tutorials.\n\n## Installation\n\nTo install ``pocomc`` using ``pip`` run:\n\n```bash\npip install pocomc\n```\n\nor, to install from source:\n\n```bash\ngit clone https://github.com/minaskar/pocomc.git\ncd pocomc\npython setup.py install\n```\n\n## Basic example\n\nFor instance, if you wanted to draw samples from a 10-dimensional Rosenbrock distribution with a uniform prior, you would do something like:\n\n```python\nimport pocomc as pc\nimport numpy as np\nfrom scipy.stats import uniform\n\nn_dim = 10  # Number of dimensions\n\nprior = pc.Prior(n_dim*[uniform(-10.0, 20.0)]) # U(-10,10)\n\ndef log_likelihood(x):\n    return -np.sum(10.0*(x[:,::2]**2.0 - x[:,1::2])**2.0 \\\n            + (x[:,::2] - 1.0)**2.0, axis=1)\n\nsampler = pc.Sampler(\n    prior=prior,\n    likelihood=log_likelihood,\n    vectorize=True,\n)\nsampler.run()\n\nsamples, weights, logl, logp = sampler.posterior() # Weighted posterior samples\n\nlogz, logz_err = sampler.evidence() # Bayesian model evidence estimate and uncertainty\n```\n\n\n# Attribution & Citation\n\nPlease cite the following papers if you found this code useful in your research:\n\n```bash\n@article{karamanis2022accelerating,\n    title={Accelerating astronomical and cosmological inference with preconditioned Monte Carlo},\n    author={Karamanis, Minas and Beutler, Florian and Peacock, John A and Nabergoj, David and Seljak, Uro{\\v{s}}},\n    journal={Monthly Notices of the Royal Astronomical Society},\n    volume={516},\n    number={2},\n    pages={1644--1653},\n    year={2022},\n    publisher={Oxford University Press}\n}\n\n@article{karamanis2022pocomc,\n    title={pocoMC: A Python package for accelerated Bayesian inference in astronomy and cosmology},\n    author={Karamanis, Minas and Nabergoj, David and Beutler, Florian and Peacock, John A and Seljak, Uros},\n    journal={arXiv preprint arXiv:2207.05660},\n    year={2022}\n}\n```\n\n# Licence\n\nCopyright 2022-Now Minas Karamanis and contributors.\n\n``pocoMC`` is free software made available under the GPL-3.0 License. For details see the `LICENSE` file.\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "Preconditioned Monte Carlo",
    "version": "1.2.5",
    "project_urls": {
        "Homepage": "https://github.com/minaskar/pocomc"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "86db8d47fcaec89577ed256e0343c0f17fd4bc70ecdb18208b7af01625007a9c",
                "md5": "9036d0690f981ba8560841d7497354b9",
                "sha256": "4e1c843d35a1521f45570d3d52d80404027b0bb269ebaf04452dcc3b269edf71"
            },
            "downloads": -1,
            "filename": "pocomc-1.2.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9036d0690f981ba8560841d7497354b9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 45897,
            "upload_time": "2024-09-16T17:32:51",
            "upload_time_iso_8601": "2024-09-16T17:32:51.342686Z",
            "url": "https://files.pythonhosted.org/packages/86/db/8d47fcaec89577ed256e0343c0f17fd4bc70ecdb18208b7af01625007a9c/pocomc-1.2.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c989e73520ba620d594fc3db0209ef93708296af697ef5b2356259efea3ce17",
                "md5": "712b68677d5de850501e06f84fd12f51",
                "sha256": "0850c90eff2cb401c499b5d395f7f899613ed6106bdeb4ce81090c8198eb2be2"
            },
            "downloads": -1,
            "filename": "pocomc-1.2.5.tar.gz",
            "has_sig": false,
            "md5_digest": "712b68677d5de850501e06f84fd12f51",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 46225,
            "upload_time": "2024-09-16T17:32:52",
            "upload_time_iso_8601": "2024-09-16T17:32:52.778945Z",
            "url": "https://files.pythonhosted.org/packages/5c/98/9e73520ba620d594fc3db0209ef93708296af697ef5b2356259efea3ce17/pocomc-1.2.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-16 17:32:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "minaskar",
    "github_project": "pocomc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pocomc"
}
        
Elapsed time: 0.47816s