[Numpy-discussion] help using np.correlate to produce correlograms.

Jose Guzman sjm.guzman at gmail.com
Wed Dec 10 15:40:32 EST 2014


Dear Pierre,

thank you very much for your time to correct my notebook and to point me 
in the direction of my wrong lag estimation. It has been very useful!

Best

Jose

On 09/12/14 17:23, Pierre Haessig wrote:
> Hi,
>
> Le 08/12/2014 22:02, Jose Guzman a écrit :
>> I'm trying to compute the cross correlation and cross correlograms from
>> some signals. For that, I'm testing  first np.correlate with some
>> idealized traces (sine waves) that are exactly 1 ms  separated from each
>> other. You can have a look here:
>>
>> http://nbviewer.ipython.org/github/JoseGuzman/myIPythonNotebooks/blob/master/Signal_Processing/Cross%20correlation.ipynb
>>
>> Unfortunately I am not able to retrieve the correct lag of 1 ms for the
>> option 'full'. Strange enough, if I perform an autocorrelation of any of
>> the signals,I obtain the correct value for a lags =0 ms. I' think I'm
>> doing something wrong to obtain the lags.
> I looked at your Notebook and I believe that you had an error in the
> definition of the delay. In you first cell, you were creating of delay
> of 20ms instead of 1ms (and because the sine is periodic, this was not
> obvious).
>
> In addition, to get a good estimation of the delay with cross
> correlation, you need many perdiods.
>
> Here is a modification of your notebook :
> http://nbviewer.ipython.org/gist/pierre-haessig/e2dda384ae0e08943f9a
> I've updated the delay definition and the number of periods.
>
> Finally, you may be able to automate a bit your plot by using
> matplotlib's xcorr (which uses np.correlate)
> http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.xcorr
>
> best,
> Pierre
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


-- 
Jose Guzman
http://www.ist.ac.at/~jguzman/



More information about the NumPy-Discussion mailing list