def _headMoveMeasure(A): lags = np.arange(0,24) i0 = 3 C = tsstats.acf(A[:,i0], lags) Cm = C.min() Ct = tsstats.acf(A[:,-i0], lags) Cmt = Ct.min() return -(Cm-Cmt)
def s_acf(traj, maxMissing): sigma2 = ma.array([speedWithoutReversals(trajw).var() for trajw in traj.asWindows(100.) if fractionMissing(trajw)>maxMissing]) C = ma.array([tsstats.acf(speedWithoutReversals(trajw), lags, exclude=trajw.excluded) for trajw in traj.asWindows(100.) if fractionMissing(trajw)>maxMissing]) C[np.isnan(C)] = ma.masked C = (sigma2[:,np.newaxis]*C).mean(axis=0) if len(C) == 0: C = ma.zeros((len(lags),)) C[:] = ma.masked return C
def s_acf(traj, maxMissing): sigma2 = ma.array([ speedWithoutReversals(trajw).var() for trajw in traj.asWindows(100.) if fractionMissing(trajw) > maxMissing ]) C = ma.array([ tsstats.acf(speedWithoutReversals(trajw), lags, exclude=trajw.excluded) for trajw in traj.asWindows(100.) if fractionMissing(trajw) > maxMissing ]) C[np.isnan(C)] = ma.masked C = (sigma2[:, np.newaxis] * C).mean(axis=0) if len(C) == 0: C = ma.zeros((len(lags), )) C[:] = ma.masked return C
def plotACFComparison(self, t, y, tau, dataStyle='k.', theoryStyle='r-', showPlot=True): dts = t[1:] - t[:-1] dt = dts[0] if not np.all(dts - dt < 1e-12): raise Exception('Time must be evenly sampled.') lags = np.round(tau/dt) Cdata = tsstats.acf(y, lags) plt.plot(lags*dt, Cdata, dataStyle) Ctheory = self.acf(tau) plt.plot(tau, Ctheory, theoryStyle) plt.xlabel(r'$\tau$ (s)') plt.ylabel(r'$\langle y(t) \cdot y(t+\tau) \rangle / \langle y(t) \cdot y(t) \rangle$') plt.ylim((-1, 1)) plt.xlim((tau.min(), tau.max())) plt.grid(True) if showPlot: plt.show()