[Numpy-discussion] help using np.correlate to produce correlograms.
jtaylor.debian at googlemail.com
Thu Dec 11 13:14:52 EST 2014
On 11.12.2014 19:01, Jose Guzman wrote:
> On 11/12/14 09:54, Pierre Haessig wrote:
>> The basic idea is to enable the user to select the exact range of lags
>> he wants. Unfortunately I didn't take the time to go further than the
>> specification above...
> I would be particularly interested in computing cross-correlations in a
> range of +-4000 sampling points lags. Unfortunately, my
> cross-correlations require vectors of ~8e6 of points, and np.correlate
> performs very slowly if I compute the whole range.
> I also heard that a faster alternative to compute the cross-correlation
> is to perform the product of the Fourier transform of the 2 vectors and
> then performing the inverse Fourier of the result.
Large convolutions/correlations are generally faster in fourier space as
they have O(NlogN) instead of O(N^2) complexity, for 1e6 points this
should be very significant.
You can use scipy.signal.fftconvolve to do that conveniently (with
performance optimal zero padding). Convolution of a flipped input (and
conjugated?) is the same as a correlation.
More information about the NumPy-Discussion