def getLoglik(): if len(z[0]) < 4: return np.zeros(((0))), np.zeros(((0))) _z, _logpxz = hmc.combine_samples(z[0], logpxz[0]) ll, ll_var = hmc.estimate_mcmc_likelihood(_z, _logpxz, len(z[0])) z[0] = [] logpxz[0] = [] return ll, ll_var
def est_ll(w, mean=False): for _ in range(n_burnin): doLeap(w) z_list = [] logpxz_list = [] for _ in range(n_leaps): logpxz = doLeap(w) z_list.append(z_mcmc.copy()) logpxz_list.append(logpxz.copy()) _z, _logpxz = hmc.combine_samples(z_list, logpxz_list) ll, var = estimate_mcmc_likelihood(_z, _logpxz, len(z_list), method=method) if mean: return ll.mean(), var.mean() return ll, var