Hi,
I was looking at the autocorrelation of a time series recently and it was
useful to scale the xaxis (i.e. multiply lags by the timestep of my actual
data). It's a trivial change, but it might be useful for others. Here's a
standalone version of axes.acorr:
def scaledacorr(x, stepsize=1, normed=False, detrend=mlab.detrend_none,
usevlines=False, maxlags=None, **kwargs):
import numpy as np
x = detrend(np.asarray(x))
Nx = len(x)
y = x
c = np.correlate(x, y, mode=2)
if normed: c/= np.sqrt(np.dot(x,x) * np.dot(y,y))
if maxlags is None: maxlags = Nx  1
if maxlags >= Nx or maxlags < 1:
raise ValueError('maglags must be None or strictly '
'positive < %d'%Nx)
lags = np.arange(maxlags,maxlags+1) * stepsize
c = c[Nx1maxlags:Nx+maxlags]
if usevlines:
a = vlines(lags, [0], c, **kwargs)
b = axhline(**kwargs)
else:
kwargs.setdefault('marker', 'o')
kwargs.setdefault('linestyle', 'None')
a, = plot(lags, c, **kwargs)
b = None
return lags, c, a, b

Michael Lerner, Ph.D.
IRTA Postdoctoral Fellow
Laboratory of Computational Biology NIH/NHLBI
5635 Fishers Lane, Room T909, MSC 9314
Rockville, MD 20852 (UPS/FedEx/Reality)
Bethesda MD 208929314 (USPS)
