[SciPy-user] Correlate Times?
Fri Jan 18 13:34:52 CST 2008
Travis E. Oliphant wrote:
> scipy.signal.correlate is a N-d correlation algorithm as has been
> noted. It is going to be slower for 1-d arrays. Now, there is nothing
> wrong with checking for that case and calling the 1-d version, it's just
> never been done (probably because people who only need 1-d correlation
> are already just using numpy.correlate).
Since I was doing some signal processing stuff, I figured
scipy.signal.correlate might work better, but obviously that was incorrect.
> ndimage also has N-d correlation inside it which was created much
> later. I think it is currently faster (but with different arguments
> that I don't fully understand so, I'm not sure what command would be
> Try scipy.ndimage.correlate and see how fast it is.
It looks like you can make it work like:
data2 = N.r_[data, N.zeros_like(data)]
scipy.ndimage.correlate1d(data2, data2, mode='constant')
On my machine however, timeit gives:
10 loops, best of 3: 4.62 s per loop
Which puts it between scipy.signal and straight up Numpy.
> This is part of the kind of clean-up that SciPy really needs.
Clearly. I know what I really need is a 1D correlation routine that will
run on an ND array.
Graduate Research Assistant
School of Meteorology
University of Oklahoma
More information about the SciPy-user