All problems
Parallel Tempering Swap Accept
Problem
Decide whether to swap two replicas in parallel tempering.
With log_ratio = (beta1 - beta2) * (e2 - e1), accept immediately when log_ratio >= 0; otherwise accept with probability exp(log_ratio) after random.seed(seed) followed by random.random(). Return a boolean.
Hint
The swap is a Metropolis test on the combined energy difference.
Test cases
case 1
in: [1,0.5,0.5,2,0]
expected: true
case 2
in: [0.5,2,1,0.5,0]
expected: true
case 3
in: [2,1,0.5,-1,7]
expected: false
case 4
in: [1,1,1,1,3]
expected: true
Starter codePython
def parallel_tempering_swap(beta1, e1, beta2, e2, seed):
# Your code here
pass4 test cases · run your code against them in the editor