Skip to content
Snippets Groups Projects

Add a mean-log-likelihood method to improve the ACT estimation

Merged Gregory Ashton requested to merge add-mean-log-like-to-ptemcee into master
All threads resolved!
Compare and Show latest version
1 file
+ 9
9
Compare changes
  • Side-by-side
  • Inline
@@ -648,8 +648,8 @@ def check_iteration(
nwalkers, nsteps, ndim = samples.shape
# Compute ACT tau for 0-temperature chains
tau_array = np.zeros((nwalkers, ndim))
if nsteps > ci.burn_in_fixed_discard:
tau_array = np.zeros((nwalkers, ndim))
for ii in range(nwalkers):
for jj, key in enumerate(search_parameter_keys):
if ci.ignore_keys_for_tau and ci.ignore_keys_for_tau in key:
@@ -662,7 +662,7 @@ def check_iteration(
except emcee.autocorr.AutocorrError:
tau_array[ii, jj] = np.inf
else:
tau_array = np.ones((nwalkers, ndim)) * np.inf
tau_array += np.inf
# Maximum over parameters, mean over walkers
tau = np.max(np.mean(tau_array, axis=0))
@@ -678,16 +678,16 @@ def check_iteration(
Q = get_Q_convergence(samples)
Q_list.append(Q)
# Convert to an integer
tau_int = int(np.ceil(tau)) if not np.isnan(tau) else tau
if np.isnan(tau_int) or np.isinf(tau_int):
if np.isnan(tau) or np.isinf(tau):
print_progress(
iteration, sampler, time_per_check, np.nan, np.nan,
np.nan, np.nan, False, convergence_inputs,
np.nan, np.nan, False, convergence_inputs, np.nan,
)
return False, np.nan, np.nan, np.nan, np.nan
# Convert to an integer
tau_int = int(np.ceil(tau))
# Calculate the effective number of samples available
nburn = ci.burn_in_fixed_discard + int(ci.burn_in_nact * tau_int)
thin = int(np.max([1, ci.thin_by_nact * tau_int]))
@@ -890,8 +890,8 @@ def plot_walkers(walkers, nburn, thin, parameter_labels, outdir, label,
for i, (ax, axh) in enumerate(axes):
ax.plot(
idxs[: nburn_fixed],
walkers[:, : nburn, i].T,
color="k",
walkers[:, : nburn_fixed, i].T,
color="gray",
**scatter_kwargs
)
Loading