I have 1 dimensional data series sampled at even time intervals; they are noisy but have the exactly the same (unknown) underlying curve - with one difference: they are offset in time by some unknown tau. What is the best (most robust) estimate of that tau? Also, what is an estimate that can be calculated quickly (that is not one of the moments of the distribution)?
The maximum of the cross-correlation function can be used for that.
(at least I know that it was used successfully in EEG time-series analysis, paper by Woody).
This is an example, I hacked together:
The top plot shows two noisy chirp-signals, the red one is offset by some 80 sampling points. The cross-correlation plot shows a clear peak at the correct offset. In MATLAB you can get the tau-estimate with
[xc,lags]=xcorr(y1,y2); [m,i]=max(xc); tau=lags(i);
where y1 and y2 are the two input signals.
This is the MATLAB code for generating the figure:
% generate 2 signals t = 0:0.001:0.5; y = chirp(t,0,1,150); y2= [cos(0:0.1:2*pi) y]; y2= y2(1:size(y,2)); % add noise yr =y +0.9*rand([1 size(y,2)]); y2r=y2+0.9*rand([1 size(y,2)]); % plot signals subplot( 2,1,1) plot(yr); hold on plot( y2r, 'r'); hold off % plot cross-correlation subplot( 2, 1,2) [z, lags]=xcorr(yr, y2r); plot( lags, z(1:end));
The problem is known as "time delay estimation". If the delay ("tau") is assumed to be constant, the most usual techniques are based on searching a maximum on the cross correlation function. But there are several refinements, many of which corresponds to some "generalized cross-correlation" (which are conceptually similiar to applying some pre-equalization to the signals), I've had good results with the "SCOT" generalized correlation. There are many papers, search for "generalized correlation" "Time delay" "SCOT" "PHAT" For example: http://dodreports.com/pdf/ada393232.pdf.