[SciPy-user] Correlate Times?

Travis E. Oliphant oliphant@enthought....
Thu Jan 17 23:02:29 CST 2008

Ryan May wrote:
> Hey,
> Can someone explain this to me?
> In [3]: import scipy as S
> In [5]: import scipy.signal as SS
> In [6]: from numpy.random import rand
> In [7]: up = rand(18000)
> In [10]: %timeit N.correlate(up,up,mode='full')
> 10 loops, best of 3: 829 ms per loop
> In [11]: %timeit S.correlate(up,up,mode='full')
> 10 loops, best of 3: 827 ms per loop
> In [12]: %timeit SS.correlate(up,up,mode='full')
> 10 loops, best of 3: 11.5 s per loop
> Is this a configuration problem?  If not, why does
> scipy.signal.correlate even exist?

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).

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.

This is part of the kind of clean-up that SciPy really needs.


More information about the SciPy-user mailing list