Skip to content
Snippets Groups Projects
Commit aa595a6a authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Fix bugs in fixed burnin

parent c39f657f
No related branches found
No related tags found
1 merge request!842Add a mean-log-likelihood method to improve the ACT estimation
Pipeline #160678 passed
......@@ -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
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment