MCMC

This module implements various proximal MCMC algorithms. The base class PxMCMC implements some basic (mostly private) functions that should be common to all algorithms. When creating a new algorithm, a class should inherit the PxMCMC class and implement at least the run() method.

class mcmc.PxMCMCParams(lmda=3e-05, delta=1e-05, s=1, mu=1, nsamples=1000000, nburn=1000, ngap=100, complex=False, verbosity=100, track=['logposterior', 'L2', 'prior', 'chain'])

Class to store tuning and runtime parameters

Parameters
  • lmda – prox parameter. tuned to make proxf abritrarily close to f

  • delta – Forward-Euler approximation step-size (MYULA, PxMALA)

  • mu – regularization parameter

  • s – max order of Chebyshev polynomials (SKROCK)

  • nsamples – number of desired samples to be saved

  • nburn – burn-in size

  • ngap – Thinning parameter=number of iterations between saved samples

  • complexTrue if sampled parameters are complex. Default False.

  • verbosity – print every verbosity samples to console

  • track – list of variables to keep track of

class mcmc.PxMCMC(forward, prior, mcmcparams=<mcmc.PxMCMCParams object>)

Base class with general PxMCMC functions. Children of this class must implement a run function.

Parameters
run(start_point=None)

Implementation of the MCMC

Parameters

start_point – vector of model parameters for the start point of the chain (default None).

logpi(X, preds)

Calculates the log(posterior), L2-norm and prior-norm of a model.

Parameters
  • X – vector of model parameters

  • preds – vector of data predictions from model X

class mcmc.MYULA(forward, prox, mcmcparams=<mcmc.PxMCMCParams object>)

Implements the MYULA chain

run(start_point=None)

Run the algorithm

chain_step(X, proxf, gradg)

Takes a step in the chain.

Parameters
  • X – current sample

  • proxf – prox of prior probablity

  • grardg – gradient of data fidelity

class mcmc.PxMALA(forward, prox, mcmcparams=<mcmc.PxMCMCParams object>, tune_delta=True)

Implements the PxMALA algorithm (MYULA + MH acceptance)

Parameters

tune_delta (bool) – if True, tunes delta parameter to achieve an acceptance probablity of 0.5

Todo

Option to tune delta to any desired acceptance probability.

run(start_point=None)

Run the algorithm

calc_logtransition(X1, X2, proxf, gradg)

Calculates the transition probability of stepping from model X1 to model X2 i.e. q(X2|X1).

class mcmc.SKROCK(forward, prox, mcmcparams=<mcmc.PxMCMCParams object>)

Implements the SKROCK algorithm

Warning

This algorithm hasn’t been used in practice yet from this code package

run(start_point=None)

Run the algorithm

chain_step(X)

Takes a step in the chain.

Parameters

X – current sample