Skip to contents

Runs K Metropolis chains at ascending temperatures and periodically proposes swaps between neighbours, accepting with the Earl-Deem (2005) eq. (4) probability. Hot replicas cross energy barriers freely and hand good configurations down the ladder, so the cold chain mixes on multimodal targets where a single chain would stay trapped.

Usage

morie_ptmcmc(
  log_p,
  temperatures,
  x0,
  n_iter = 1000L,
  step = 1,
  seed = 0,
  swap_every = 1L
)

Arguments

log_p

Unnormalised log density of one number.

temperatures

Ascending positive temperatures; the first is the target.

x0

Common starting value.

n_iter

Number of sweeps.

step

Proposal scale at temperature 1.

seed

Seed for the generator shared with the Python arm.

swap_every

Sweeps between swap attempts.

Value

A list with chain (the cold chain), chains_last, accept_rate, swap_accept_rate, temperatures, n_iter, seed, method.

References

Earl, D. J. and Deem, M. W. (2005). Parallel tempering: theory, applications, and new perspectives. Physical Chemistry Chemical Physics, 7, 3910-3916.

Examples

# a bimodal target; the hot replicas carry the cold chain between the modes
log_p <- function(x) log(0.5 * dnorm(x, -4) + 0.5 * dnorm(x, 4))
r <- morie_ptmcmc(log_p, temperatures = c(1, 3, 9), x0 = 0, n_iter = 2000L, seed = 1)
mean(r$chain > 0)
#> [1] 0.465