Coding Cross Correlation Function in Python

sturlamolden sturlamolden at yahoo.no
Wed Dec 2 14:12:11 EST 2009


On 2 Des, 18:50, DarthXander <DarthXan... at hotmail.co.uk> wrote:

> However to do this 700 times seems ridiculous. How would I get python
> to perform this for me for t in a range of roughly 0-700?

For two 1D ndarrays, the cross-correlation is

from numpy.fft import rfft, irfft
from numpy import fliplr

xcorr = lambda x,y : irfft(rfft(x)*rfft(fliplr(y)))

Normalize as you wish, and preferably pad with zeros before invoking
xcorr.








More information about the Python-list mailing list