Hello, I'm trying to gain understanding of cross correlation practical use. My textbook (among others) define auto and cross correlation and states they are both widely used in signal processing and detecting signals with noise. So, I simply want to learn how to use it effectively. I made simple script in MATLAB: t = 0:0.1:10; %time x = 2*sin(t); plot(x) z = randn(1,length(t)); hold on; plot(z,'r'); xcorrelation = xcorr(x,z); figure(2) plot(correlation,'g'); hold on acorrelation = xcorr(x,x) plot(acorrelation,'m'); I wanted to see how cross corelation look like when signal (sinusiod) is correlated with itself and with noise. If you execute this script, you'll see that auto correlation of sinusoids has much higher amplitude then cross correlation (noise nad sinusoide) as expected. Now I'm trying to figure out how to make practical use of that? What treshold to set in order to make a guess if signal is sinusoid ore something else? I simply don't know what to do further. Can you explain a little bit more? I hope there are people here who use correlation in practice and research and who can give one or two useful advices. Thank you

# Cross correlation in signal analysis

Started by ●April 18, 2008

Reply by ●April 18, 20082008-04-18

On Apr 18, 12:16�pm, brob...@yahoo.com wrote:> Hello, > I'm trying to gain understanding of cross correlation practical use. > My textbook (among others) define auto and cross correlation and > states they are both widely used in signal processing and detecting > signals with noise.An 1024 point FFT is basically a cross correlation between the input signal and 1024 different sinusoids, with excellent noise rejection due to the reduction in BW of each output bin vs the BW of the input signal (with certain assumptions made about the noise characteristics). So I guess that's a practical use you can look into and think about.

Reply by ●April 18, 20082008-04-18

>If you execute this script, you'll see that auto correlation of >sinusoids has much higher amplitude then cross correlation (noise nad >sinusoide) as expected.Do you mean noise alone correlated with the sinusoid? Yes, if this is the case, since AWGN is uncorrelated with a sinusoid.>Now I'm trying to figure out how to make practical use of that? What >treshold to set in order to make a guess if signal is sinusoid ore >something else? >I simply don't know what to do further. >Can you explain a little bit more? I hope there are people here who >use correlation in practice and research and who can give one or two >useful advices.What are you looking for? The correlator receiver is identical to a matched filter. One common application is the RAKE receiver used in DS-CDMA applications (PCS phones). Each user in such a system is spread with a unique code, orthogonal to other users (for forward link, i.e., base to phone, these are typically Walsh codes). The input signal is correlated with the desired user code (including the scrambling code) in order to extract the signal from the aggregate transmission. The term RAKE comes from the fact that the receiver has several correlators, each shifted in time to obtain signals that result from multipath (a result of reflection/refraction). For a single signal transmitted through an AWGN channel, the correlator is an optimal (minimum mean-square error sense) detector. With the addition of other impairments, e.g., Rayleigh fading resulting from multipath, or other signals that are not orthogonal to the desired signal, the detector is no longer MMSE optimal. There are a variety of methods that approach an optimal detector, which is probably beyond what you are interested in. Mark

Reply by ●April 18, 20082008-04-18

On Apr 19, 7:16 am, brob...@yahoo.com wrote:> Hello, > I'm trying to gain understanding of cross correlation practical use. > My textbook (among others) define auto and cross correlation and > states they are both widely used in signal processing and detecting > signals with noise. So, I simply want to learn how to use it > effectively. > I made simple script in MATLAB: > t = 0:0.1:10; %time > x = 2*sin(t); > plot(x) > z = randn(1,length(t)); > hold on; > plot(z,'r'); > > xcorrelation = xcorr(x,z); > figure(2) > plot(correlation,'g'); > hold on > acorrelation = xcorr(x,x) > plot(acorrelation,'m'); > > I wanted to see how cross corelation look like when signal (sinusiod) > is correlated with itself and with noise. > If you execute this script, you'll see that auto correlation of > sinusoids has much higher amplitude then cross correlation (noise nad > sinusoide) as expected. > Now I'm trying to figure out how to make practical use of that? What > treshold to set in order to make a guess if signal is sinusoid ore > something else? > I simply don't know what to do further. > Can you explain a little bit more? I hope there are people here who > use correlation in practice and research and who can give one or two > useful advices. > Thank youLocating a sound uses cross correlation. Using two microphones you can deduce the bearing (though it is not unique). The time delay bewteen microphones is estimated using cc. However, you will find that ordinary cc only gives well defined peaks if the (random) signals are white. This is not much use since speech is always coloured. Therefore Generalized Cross Correlation is used - an extension using a weighting function and FFTs. K.

Reply by ●April 20, 20082008-04-20

On Apr 18, 3:16�pm, brob...@yahoo.com wrote:> Hello, > I'm trying to gain understanding of cross correlation practical use. > My textbook (among others) define auto and cross correlation and > states they are both widely used in signal processing and detecting > signals with noise. So, I simply want to learn how to use it > effectively. > I made simple script in MATLAB: > t = 0:0.1:10; %time > x = 2*sin(t); > plot(x) > z = randn(1,length(t)); > hold on; > plot(z,'r'); > > xcorrelation = xcorr(x,z); > figure(2) > plot(correlation,'g'); > hold on > acorrelation = xcorr(x,x) > plot(acorrelation,'m'); > > I wanted to see how cross corelation look like when signal (sinusiod) > is correlated with itself and with noise. > If you execute this script, you'll see that auto correlation of > sinusoids has much higher amplitude then cross correlation (noise nad > sinusoide) as expected. > Now I'm trying to figure out how to make practical use of that? What > treshold to set in order to make a guess if signal is sinusoid ore > something else? > I simply don't know what to do further. > Can you explain a little bit more? I hope there are people here who > use correlation in practice and research and who can give one or two > useful advices. > Thank youAuto correlation is used to determine if there is an �echo� or time- delayed version(s) of a signal in the data from one sensor. It�s performed by taking the FFT of the sensor data, multiplying the transform with its complex conjugate, inverse transforming, and then using a peak detector on the output. The peak(s) in the output tell you the time delay or delays, if there are multiple echoes. Mathematically, auto correlation is similar to the convolution of a signal with itself (F[k] below is the transform of the signal): convolution: F[k] times F[k] then inverse transform auto correlation: F[k] times F[k]* (* = conjugate) then inverse transform The reason for the conjugation operation has to do with the fact that you don�t want that �time reversal� thing that happens with convolution. As with convolution, you should zero-pad to avoid doing a circular auto correlation. Cross correlation is used to determine if there is a time delay between a signal arriving at two spatially separate sensors. It�s performed by taking the FFTs of data from each sensor, conjugating one of them, multiplying them, point by point, and then inverse transforming. Once again, you should zero-pad to avoid circular cross correlation. If there is a strong, unwanted sinusoid in your input, then the result of the cross correlation will be based on the strong unwanted sinusoid. You can minimize the effect of the unwanted component by using a window function in the frequency domain prior to inverse transforming. That is, FFT each sensor, conjugate one result, multiply the transforms, multiply by the window, inverse transform, then peak detect. But note that the window functions (there are several, some much better than others) are NOT like the window functions (e.g.: Hann, Hamming, etc.) used to minimize leakage and picket fence effects. Here�s 3 references that may help: J. C. Hassab, R. E. Boucher, �Optimum Estimation of Time Delay by a Generalized Correlator,� IEEE T-ASSP, vol. 27, no. 4, Aug. 1979, pp. 373-380. J. C. Hassab, R. E. Boucher, �Performance of the Generalized Cross Correlator in the Presence of a Strong Spectral Peak in the Signal,� IEEE T-ASSP, vol. 29, no. 3, June 1981, pp. 549-555. J. C. Hassab, R. E. Boucher, �An Experimental Comparison of Optimum and Sub-Optimum Filters� Effectiveness in the Generalized Correlator,� J. Sound and Vibration, 1981, (12 pages total - I got this as a class handout, and it doesn�t have the page numbers).

Reply by ●April 20, 20082008-04-20

Thank you for the explanation. I'm beginer in the subject and there is one more thing that I need to understand. That is "real" definition of correlation. In one of my textbook there is example of cross correlation of stohastic signals x(t) and y(t). Cross correlation is defined as: C(tau) = (1/N)*sum( x(n)*y(n+tau) ) when N ->inf, while in other cros correlation is defined as sum( x(n) * y(n+tau) ). I notoced that same definition is used by Matlab's function xcorr. I'm really confused, it seems that definitions are different for deterministic and stohastic signals...

Reply by ●April 20, 20082008-04-20

<kevinjmcgee@netscape.net> wrote in message news:85a61687-ddb3-41e3-bf58-27f8a9ff0f27@k10g2000prm.googlegroups.com...> Auto correlation is used to determine > if there is an �echo� or time- > delayed version(s) of a signal in the > data from one sensor. It�s > performed by taking the FFT of the > sensor data, multiplying the > transform with its complex conjugate, > inverse transforming, and then > using a peak detector on the output. > The peak(s) in the output tell > you the time delay or delays, if there > are multiple echoes. > Mathematically, auto correlation is > similar to the convolution of a > signal with itself (F[k] below is > the transform of the signal): > > convolution: > F[k] times F[k] then > inverse transform > auto correlation: > F[k] times F[k]* (* = conjugate) then > inverse transform[snip]> Cross correlation is used to determine > if there is a time delay > between a signal arriving at two > spatially separate sensors. It�s > performed by taking the FFTs of data > from each sensor, conjugating one > of them, multiplying them, point by > point, and then inverse > transforming. Once again, you should > zero-pad to avoid circular cross > correlation.[snip] Thanks for an unusually informative post.

Reply by ●April 20, 20082008-04-20

On Apr 20, 5:23�am, brob...@yahoo.com wrote:> Thank you for the explanation. I'm beginer in the subject and there is > one more thing that I need to understand. That is "real" definition of > correlation. In one of my textbook there is example of cross > correlation of stohastic signals x(t) and y(t). Cross correlation is > defined as: > C(tau) = (1/N)*sum( x(n)*y(n+tau) ) when N ->inf, while in other cros > correlation is defined as sum( x(n) * y(n+tau) ). I notoced that same > definition is used by Matlab's function xcorr. I'm really confused, it > seems that definitions are different for deterministic and stohastic > signals...We were all beginners at some time or another. For some things, I still am. A �real� definition of correlation can be found in Wikipedia. But perhaps you won�t need it. Correlation is a measure of similarity. If you have 2 identical waveforms, then they will be correlated with a correlation coefficient of 1 (look up the equation of correlation coefficient - it�s very similar to what a DFT does). If the waveforms are exactly the opposite of each other, the correlation coefficient will be -1. Waveforms that are dissimilar will have a correlation coefficient somewhere between the two extremes of 1 and -1. There�s also a definition of �stochastic� (Wikipedia also has it). A stochastic signal is random, like a coin toss. I wouldn�t worry about the 1/N part of the one definition you have for the cross correlation. Ask yourself this: can you calculate something to infinity? I don�t think so (and if you can, please tell the rest of us, because we�d really like to know). Your MATLAB definition seems correct: sum( x(n) * y(n+tau) ). I�m probably not the best person to ask, since I use C or C++ compilers to test things, and I don�t know much about MATLAB. As for being confused about deterministic and stochastic signal, it�s probably due to my previous explanation not being clear enough. Let�s say you have a signal. Perhaps it�s a strong sinusoid (deterministic). In that case, the cross correlation would yield a result that corresponds to the time delay between the deterministic signal arriving at the 2 sensors at different times. Perhaps you may have a little bit of noise to deal with. For a strong signal to noise ratio, this will work out fine. But suppose your signal is weak Gaussian noise (stochastic). The cross correlation will still give you the time delay. But suppose furthermore that there is a strong sinusoidal �noise� signal present. Your time delay estimate of the weaker stochastic signal will be corrupted by the strong sinusoid. You�d have to eliminate it somehow from your processing. That�s why you use the windowing in my original response. The lower signal to noise ratio problems are more difficult than strong signal to noise problems, which is why most people tend to focus on them. I hope this clears things up.