def get_function(x):
n_t, n_w = x.shape
f = np.zeros(n_t)
for k in range(n_w):
f += emcee.autocorr.function_1d(x[:, k])
f /= n_w
return f
fig, axes = plt.subplots(2, 2, figsize=(10, 8))
ax = axes[0, 0]
t_emcee = np.linspace(0, time_emcee, samples_emcee.shape[0])
m = t_emcee < 5
ax.plot(t_emcee[m], samples_emcee[m, 5, 0], lw=0.75)
ax.annotate(
"emcee",
xy=(0, 1),
xycoords="axes fraction",
ha="left",
va="top",
fontsize=16,
xytext=(5, -5),
textcoords="offset points",
)
ax.set_ylabel(r"$\theta_1$")
ax.set_xlim(0, 5)
ax.set_ylim(-4, 4)
ax.set_xticklabels([])
ax = axes[1, 0]
t_pymc3 = np.linspace(0, time_pymc3, samples_pymc3.shape[0])
m = t_pymc3 < 5
ax.plot(t_pymc3[m], samples_pymc3[m, 0, 0], lw=0.75)
ax.annotate(
"pymc3",
xy=(0, 1),
xycoords="axes fraction",
ha="left",
va="top",
fontsize=16,
xytext=(5, -5),
textcoords="offset points",
)
ax.set_ylabel(r"$\theta_1$")
ax.set_xlabel("walltime [s]")
ax.set_xlim(0, 5)
ax.set_ylim(-4, 4)
ax = axes[0, 1]
f_emcee = get_function(samples_emcee[:, :, 0])
scale = 1e3 * time_emcee / np.prod(samples_emcee.shape[:2])
ax.plot(scale * np.arange(len(f_emcee)), f_emcee)
ax.axhline(0, color="k", lw=0.5)
ax.annotate(
"emcee",
xy=(1, 1),
xycoords="axes fraction",
ha="right",
va="top",
fontsize=16,
xytext=(-5, -5),
textcoords="offset points",
)
val = 2 * scale * tau_emcee[0]
max_x = 1.5 * val
ax.axvline(val, color="k", lw=3, alpha=0.3)
ax.annotate(
"{0:.1f} ms".format(val),
xy=(val / max_x, 1),
xycoords="axes fraction",
ha="right",
va="top",
fontsize=12,
alpha=0.3,
xytext=(-5, -5),
textcoords="offset points",
)
ax.set_xlim(0, max_x)
ax.set_xticklabels([])
ax.set_yticks([])
ax.set_ylabel("autocorrelation")
ax = axes[1, 1]
f_pymc3 = get_function(samples_pymc3[:, :, 0])
scale = 1e3 * time_pymc3 / np.prod(samples_pymc3.shape[:2])
ax.plot(scale * np.arange(len(f_pymc3)), f_pymc3)
ax.axhline(0, color="k", lw=0.5)
ax.annotate(
"pymc3",
xy=(1, 1),
xycoords="axes fraction",
ha="right",
va="top",
fontsize=16,
xytext=(-5, -5),
textcoords="offset points",
)
val = 2 * scale * tau_pymc3[0]
ax.axvline(val, color="k", lw=3, alpha=0.3)
ax.annotate(
"{0:.1f} ms".format(val),
xy=(val / max_x, 1),
xycoords="axes fraction",
ha="left",
va="top",
fontsize=12,
alpha=0.3,
xytext=(5, -5),
textcoords="offset points",
)
ax.set_xlim(0, max_x)
ax.set_yticks([])
ax.set_xlabel("walltime lag [ms]")
ax.set_ylabel("autocorrelation")
fig.subplots_adjust(hspace=0.05, wspace=0.15)
fig.savefig("gaussians.pdf", bbox_inches="tight");