[SciPy-user] Autocorrelation
David Huard
david.huard at gmail.com
Tue Aug 15 13:41:35 EDT 2006
Turns out its quicker to write one, than to find one...
def autocorr(x, lag=1):
"""Returns the autocorrelation x."""
x = squeeze(asarray(x))
mu = x.mean()
s = x.std()
return ((x[:-lag]-mu)*(x[lag:]-mu)).sum()/(s**2)/(len(x) - lag)
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20060815/44892470/attachment.html>
More information about the SciPy-User
mailing list