based on the implementation example (using R & RStan) on this site
-
NumPy
-
PyStan
pip install git+https://github.com/narrowlyapplicable/stanRepEx
from stanRepEx import ReplicaExchange, ReplicaExchangeParallel
data = {} # standata (empty in this example)
init = dict(p=np.array([0, 0])) # initial value of the parameter to be estimated
N_rep = 30 ## number of replicas
N_ex = 200 ## number of exchanges
Inv_T = 0.5 ** np.linspace(0, -np.log(0.2)/np.log(2), num=N_rep)
# w/o Parallelization
replica_exchange = ReplicaExchange(n_ex=N_ex, inv_T=Inv_T, stanmodel=stanmodel)
result = replica_exchange.sampling(data=data, par_init=init, n_iter=70, warmup=50)
# with Parallelization
replica_exchange = ReplicaExchangeParallel(n_ex=N_ex, inv_T=Inv_T, stanmodel=stanmodel)
result = replica_exchange.sampling(data=data, par_init=init, n_iter=70, warmup=50)