Skip to contents

K random-walk Metropolis replicas at ascending temperatures with neighbour swaps accepted with probability min(1, exp((1/T_k - 1/T_{k+1})(lp_{k+1} - lp_k))) (Earl-Deem 2005 eq. 4; Hukushima-Nemoto 1996). Proposal sd scales with sqrt(T_k). Bit-identical stream consumption with the Python arm: one normal and one uniform per replica per sweep, one uniform per swap attempt.

Usage

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

Arguments

log_p

Log target density (the T = 1 target).

temperatures

Ascending positive temperatures, first 1.0.

x0

Scalar start.

n_iter

Sweeps.

step

Base proposal sd.

seed

SplitMix64 seed.

swap_every

Swap attempt period.

Value

List with chain (cold trace), chains_last, accept_rate, swap_accept_rate, temperatures, n_iter, seed, method.

References

Earl, D. J. and Deem, M. W. (2005), Phys. Chem. Chem. Phys. 7, 3910-3916, eq. 4; Hukushima, K. and Nemoto, K. (1996), J. Phys. Soc. Japan 65(6), 1604-1608; Metropolis et al. (1953), J. Chem. Phys. 21, 1087-1092.

Examples

r <- Ptmcmc(function(x) -0.5 * ((x - 1)^2) * ((x + 1)^2),
            temperatures = c(1, 2, 4), x0 = 0, n_iter = 400)
str(r, max.level = 1)
#> List of 8
#>  $ chain           : num [1:400] -1.398 0.039 1.241 -0.689 1.026 ...
#>  $ chains_last     : num [1:3] -0.54 0.854 -0.147
#>  $ accept_rate     : num [1:3] 0.652 0.66 0.537
#>  $ swap_accept_rate: num [1:2] 0.89 0.88
#>  $ temperatures    : num [1:3] 1 2 4
#>  $ n_iter          : int 400
#>  $ seed            : int 0
#>  $ method          : chr "Parallel tempering (Earl-Deem 2005 eq. 4; Hukushima-Nemoto 1996)"