Skip to content

Commit 71721f8

Browse files
committed
Fixes autocorrelation function
1 parent c07d1c3 commit 71721f8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: pylib/analysis.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,12 @@ def bin_data(x, *, binsize, silent_trunc=True):
110110

111111
# Autocorrelations
112112
def compute_autocorr(Os, *, tmax, vacsub=True):
113+
assert np.allclose(np.imag(Os), 0.0)
113114
if vacsub:
114115
dOs = Os - np.mean(Os)
115116
else:
116117
dOs = Os
117-
Gamma = np.array([np.mean(dOs[t:] - dOs[:-t]) for t in range(1,tmax)])
118+
Gamma = np.array([np.mean((dOs[t:] - dOs[:-t])**2) for t in range(1,tmax)])
118119
Gamma = np.insert(Gamma, 0, np.mean(dOs**2))
119120
rho = Gamma / Gamma[0]
120121
return rho

0 commit comments

Comments
 (0)