[SciPy-user] Autocorrelation

David Huard david.huard at gmail.com
Tue Aug 15 12:41:35 CDT 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://projects.scipy.org/pipermail/scipy-user/attachments/20060815/44892470/attachment.html 


More information about the SciPy-user mailing list