Skip to content

Commit c3a4cba

Browse files
committed
Added small check for agreement between actual acceptance rate and average acceptance rate
1 parent a943826 commit c3a4cba

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/alphas/analysis/data_app.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,17 @@ def proper(data):
262262
tplaq = np.array(data['temporal plaquette'])
263263

264264
# fcn(dH)
265-
dH = np.array(data['dH'])
265+
dH = np.array(data['dH']) #np.array([d for idx,d in enumerate(data['dH']) if not data['cut'][idx]])
266+
dH_cut = [d for idx,d in enumerate(data['dH']) if not data['cut'][idx]]
266267
#dH = np.array([dh if data['acceptance'][c] else 0.0 for c,dh in enumerate(data['dH'])])
267268
dH2 = dH*dH
268269
expdH = np.exp(-dH)
269-
pred_acc_rate = int(round(scipy.special.erfc(np.sqrt(np.mean(dH2)/8.))*100.))
270-
270+
expdH_cut = [d for idx,d in enumerate(expdH) if not data['cut'][idx]]
271+
dH2_cut = [d for idx,d in enumerate(dH2) if not data['cut'][idx]]
272+
pred_acc_rate = int(round(scipy.special.erfc(np.sqrt(np.mean(dH2_cut)/8.))*100.))
273+
acc_rate = [min(1.0, expdh) for expdh in expdH_cut]
274+
avg_acc_rate = int(round(np.mean(acc_rate)*100.))
275+
271276
# cg iterations
272277
hcg = data['average CG iterations (hasenbusch)']
273278
fcg = data['average CG iterations (fermion)']
@@ -384,7 +389,11 @@ def plot_hmc_observable(h, meas, lbl, bins = None, range = None):
384389
st.latex("""
385390
P \\approx \mathrm{erfc}\\bigg[\\frac{1}{8}\\Big\\langle \mathrm{d}\mathcal{H}^2 \\Big\\rangle^{1/2} \\bigg]
386391
""")
387-
st.markdown(f"yielding $P \\approx {pred_acc_rate}\%$ for the present simulation.")
392+
st.markdown(f"yielding $P \\approx {pred_acc_rate}\%$ for the present simulation. We also have for the average acceptance rate")
393+
st.latex("""
394+
P = \langle \mathrm{min}(1, \exp(-\mathrm{d}\mathcal{H})) \\rangle,
395+
""")
396+
st.markdown(f"yielding $P \\approx {avg_acc_rate}\%$")
388397

389398
# dH
390399
dhp = plot.Plot(h = 2.25)

0 commit comments

Comments
 (0)