def __init__(self, opts, num_chains, max_temp, min_temp=1, swap_period=20): self.options = opts self.max_temp = max_temp self.min_temp = min_temp self.swap_period = swap_period self.iter = 0 """Current step iteration (runs to ``nsteps``).""" self.chains = [] """The set of chains in the temperature series.""" # Calculate the temperature series temps = np.logspace(np.log10(min_temp), np.log10(max_temp), num_chains) # Initialize each of the chains for i, temp in enumerate(temps): chain = MCMC(opts) chain.options.T_init = temp chain.initialize() chain.iter = chain.start_iter self.chains.append(chain) # Initialize arrays for storing swap info num_swaps = self.options.nsteps / swap_period self.swap_proposals = np.zeros((num_swaps, 2)) """Each swap proposal is stored as [i, j] row in this array.""" self.pi_xi = np.zeros(num_swaps) """The posterior of chain i at the position of i.""" self.pi_xj = np.zeros(num_swaps) """The posterior of chain i at the position of j.""" self.pj_xi = np.zeros(num_swaps) """The posterior of chain j at the position of i.""" self.pj_xj = np.zeros(num_swaps) """The posterior of chain j at the position of j.""" self.delta_test_posteriors = np.zeros(num_swaps) """The posterior probability ratio for swap/noswap.""" self.swap_alphas = np.zeros(num_swaps) """The random number used to accept/reject the swap.""" self.swap_accepts = np.zeros(num_swaps, dtype=bool) """Booleans indicating accepted swaps.""" self.swap_rejects = np.zeros(num_swaps, dtype=bool) """Booleans indicating rejected swaps.""" self.swap_iter = 0 """Current swap iteration (runs to ``nsteps / swap_period``)"""