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.6.3.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

reddemcee-0.6.3-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: reddemcee-0.6.3.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for reddemcee-0.6.3.tar.gz
Algorithm Hash digest
SHA256 068155d5a0b2a70e6f7fbedccc4d80821d708b9e2eb4fc0c8a3822935c037f0d
MD5 12eeec0596d8965af26f8cf661189e6b
BLAKE2b-256 b1075d61177824c781ea43a324f888abb28a0336920feb0e07e847c43097a807

See more details on using hashes here.

File details

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

File metadata

  • Download URL: reddemcee-0.6.3-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for reddemcee-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c0114ccdb48e67f7c6bc560b3cccd55991609f3eaa0c304ee3da9746de370f35
MD5 38ebe821f7b31a32c813f06c9bd1765c
BLAKE2b-256 45acbbd4311d3fe57e325ca77e737a34b1689f3e48ed6c1222146fbce76c0989

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page