How do I know if the finddelay function is significant?

16 views (last 30 days)
Emelie Leht on 27 Apr 2013
I am currently using the finddelay function to visualize a wave pattern. I have a matrix with periodic signals recorded and I use one of the signals as a reference to which I compare all of the others to achieve a matrix of delays which I then visualize as different colours in a matrix plot.
I my case I would assume to have sufficient correlation with the majority of the signals but what do the function actually return for the few that does not have a correlation? Will I get 0 as delay? I have looked into the code of the function but could not figure it out by myself. Would it be possible to adapt the function to get it to return a special value when there is no correlation so that I could single out and mark theses spots in my plot?
Related to this I also wonder if there is some general rule of how long this type of signals should be for the finddelay function to be applicable?
Thank you, Emelie

Wayne King on 28 Apr 2013
Edited: Wayne King on 28 Apr 2013
It is not true that you will get back a delay of zero for cases when the signals are not significantly correlated at any lag.
rng default;
x = randn(100,1);
y = randn(100,1);
[xc,lags] = xcorr(x,y,20,'coeff');
[rho,idx] = max(abs(xc));
lags(idx)
And cross-correlation sequences that achieve a maximum at zero lag can certainly indicate significant cross-correlation. Think about the autocorrelation of a sequence.
Depending on what distributional assumptions you can reasonably make about your signals, it may well be possible to come up with a principled threshold for significant cross-correlation, but just for the moment, let's assume you want to see at least 0.5
You can do something like this
[xc,lags] = xcorr(x,y,20,'coeff');
[rho,lags] = max(abs(xc));
if (rho>=0.5)
Lag = lags(idx);
else
Lag = NaN;
end
Emelie Leht on 29 Apr 2013
I see what you are doing and why it would work. I know that a zero lag in cross correlation is not an indication of no correlation but rather a high correlation. However,I am not sure I was clear about it before, but the finddelay function I am using is an already implemented function by Matlab that is based on the xcorr function and will deliver me the delays directly and in this case a delay of zero even if there is no correleation. Documentation of the function can be found here: http://www.mathworks.nl/help/comm/ref/finddelay.html
I had a look at its code by typing: type finddelay
into Matlab and from that I understood that I would have a zero returned by the function even if there was no correlation by the signals. Since this finddelay function already makes use of the xcorr I thought it was a bit of double work to implement the xcorr again. Also, the reason I rather use the finddelay is that it can handle multiple signals at the same time while the xcorr only operates on one signal and its reference at a time which would require a lot of iteration in my case since I have a matrix of signals that I want to compare. Hope I made my case more clear!
//Emelie

Wayne King on 27 Apr 2013
If the signals are equal length, then why not use xcorr() with the 'coeff' option?
Then the cross-correlation will lie in the range [-1,1] and you pretty easily assess how significant the cross-correlation is when it achieves its maximum.