Skip to main content

An Adaptative Parallel Tempering wrapper for emcee 3 for personal use

Project description

Reddemcee

An Adaptative Parallel Tempering wrapper for emcee 3 for personal use, which someone in the community might find useful on it's own.

Overview

Reddemcee is simply a wrapper for the excellent MCMC implementation emcee, that contains an adaptative parallel tempering version of the sampler, according to Vousden et al. implementation. It's coded in such a way that minimal differences in input are required, and it's fully compatible with emcee (v. 3.1.3).

Dependencies

This code makes use of:

Most of them come with conda, if some are missing they can be easily installed with pip.

Installation

In the console type in your work folder

pip install reddemcee

Usage

Please refer to the test file in the tests folder.

import numpy as np
import reddemcee

def log_like(x, ivar):
    return -0.5 * np.sum(ivar * x ** 2)

def log_prior(x):
    return 0.0

ndim, nwalkers = 5, 100
ntemps = 5
ivar = 1. / np.random.rand(ndim)
p0 = list(np.random.randn(10, nwalkers, ndim))
sampler = reddemcee.PTSampler(nwalkers,
                             ndim,
                             log_like,
                             log_prior,
                             ntemps=ntemps,
                             adaptative=True,
                             logl_args=[ivar],
                             )
                             
sampler.run_mcmc(p0, 100, 2)  # starting pos, nsweeps, nsteps

Additional Options

ntemps betas pool adaptative config_adaptation_halflife rn: adaptations reduced by half at this time config_adaptation_rate rn: smaller, faster moves backend

Stored

ratios betas_history betas_history_bool ratios_history

Funcs

thermodynamic_integration(self, coef=3, sampler_dict = {'flat':False, 'discard':10})

get_Z(discard=1, coef=3, largo=100) get_attr(x) get_func(x)

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

reddemcee-0.8.5.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

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

reddemcee-0.8.5-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file reddemcee-0.8.5.tar.gz.

File metadata

  • Download URL: reddemcee-0.8.5.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for reddemcee-0.8.5.tar.gz
Algorithm Hash digest
SHA256 7c31313399470bb5408d0e99e9a6a6a52f32508e09aaa29d757c9d5e5601709b
MD5 70b88b70a6530da5869920c2c77f4deb
BLAKE2b-256 ace9c7ed993b1adc3128b581b80cd1942f7e4a3d7187b22160cc781a564e9b42

See more details on using hashes here.

File details

Details for the file reddemcee-0.8.5-py3-none-any.whl.

File metadata

  • Download URL: reddemcee-0.8.5-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for reddemcee-0.8.5-py3-none-any.whl
Algorithm Hash digest
SHA256 11a7e0188096fc42e5e59d94f3bbf5cab5b918310148368994f23705105dfd14
MD5 31017a26d2bff61ee38d190fb9170049
BLAKE2b-256 7141bc938d81657aadbb2aecf0ab38daad7d8e0e49ea8a2a43ec4c53915a2932

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