• No results found

Auto-correlation and cross-correlation

Introduction to convolution and correlation

5.4 Auto-correlation and cross-correlation

5.4.1 Definitions

Like convolution, the operations of both auto-correlation and cross-correlation involve product summations between two signals. Unlike convolution, no time reversal is applied to the signal that corresponds to the impulse response. With auto-correlation, one signal is matched against itself. In contrast, cross-correlation involves the matching of two distinct signals. The continuous equation for autocorrelation is therefore given by

y(t) =



−∞x(τ )x(t + τ ) dt, (5.17)

and for cross-correlation we have y(t) =



−∞x1(τ )x2(t + τ ) dt. (5.18)

Proceeding immediately to the discrete space and range-limited equivalent, we have, for auto-correlation:

For auto-correlation, the absence of time reversal implies that the output will reach a maximum when the two signals are exactly in phase with one another. At this point in time, each value of the signal x(t) or x[n] will effectively be squared, and these squared values will then be accumulated. For example, a discrete rectangular pulse comprising five values, each of unit height, will, when auto-correlated, yield the sequence 1, 2, 3, 4, 5, 4, 3, 2, 1 (note that for symmetrically shaped functions,

1

Figure 5.7 Auto-correlation of a triangle function

of which this is an example, it does not matter whether we employ the correlation or convolution sum).

From this simple example, we can deduce that specifically the auto-correlation function of a square pulse is always a triangular pulse. More generally, we can also see that the longer the duration of the square pulse, the greater the peak height of the auto-correlated output. In fact, for perfectly correlated signals, the peak amplitude is given by

Vp=M−1

k=0

x2[n]. (5.21)

This is extremely important since it allows us to extract signals buried in random noise by correlating signals of low amplitude but long duration (this is often done to avoid stress loading of transmission equipment; more on this in a moment). Figure 5.7 shows a convincing example of why correlation is so powerful. In part (a) is drawn a triangle function, and part (b) depicts its auto-correlation function. Note the very significant increase in peak signal magnitude. Now, the longer the original signal is, regardless of magnitude, the higher the peak of the auto-correlation function.

Figure 5.8 Cross-correlation is widely used to enhance weak signals buried in noise

5.4.2 Cross-correlation, matched filters and signal-to-noise ratio enhancement

The principle of auto-correlation is significant because it reveals how the amplitude of the signal is enhanced through repeated MAC operations. However, in practice it is often of limited value, so we normally exploit cross-correlation in order to maximise the signal-to-noise ratio (SNR) of say, a received signal. Rather than go into abstruse mathematical detail here, let us consider an example instead.

Referring to Figure 5.8, a submarine sonar system is designed to detect distant shipping or obstacles in the ocean; it transmits a burst of acoustic energy, which travels out from the receiver through the water, eventually arriving at a target. This target reflects a proportion of the incident waveform, which then travels back to the sonar, is collected by the receiving transducer, amplified and processed by the electronic instrumentation. However, for distant objects, the received signal will have minute magnitude in comparison to the original outgoing waveform (most of the signal will actually miss the detector). In addition, it will be degraded by noise from a variety of waterborne sources. In extreme cases, it may not be possible, in the original received echo, to distinguish between the noise floor and the signal. This is where cross-correlation can play a vital role in the identification of the echo (Lewis, 1997). The way it works is as follows: before the outgoing signal is amplified and transmitted, a copy of the waveform is stored in digital form, which we call x1[n].

The received signal is then digitised, which we now call x2[n] and cross-correlated with the stored version of the transmission signal, using Equation (5.20) (it is also possible to do this using the original continuous time signals but the analog electronic systems are less flexible and can be difficult to design).

If you look on the CD that accompanies this book, in the folder Applications for Chapter 5\Correlation\, you will find a program called Correlation.exe, a screenshot of which is shown in Figure 5.9. This program demonstrates just how powerful a technique cross-correlation is in extracting signals buried in noise. The program

Figure 5.9 Screenshot of correlation.exe

generates an initial signal x1[n] either as a tone burst signal, or a random bit sequence depending on the selection indicated in the group box entitled Signal type. The number of cycles can be varied from between 1 and 50, depending on the position of the first scroll bar in the group box entitled Signal x1[n] generation. The program also mixes this signal with random noise, the amplitude of which is set by the position of the second scroll bar in the group box entitled Noise amplitude. The combined signal is now called x2[n] and is plotted in the upper graphical window. To view the tone burst or random bit sequence in isolation, simply move this second scroll bar to the left so that the noise amplitude is zero. The program automatically performs a cross-correlation of x1[n] and x2[n] and displays the result in the lower graphical window. By default, the software generates a ten cycle tone burst with an amplitude of 0.2, embedded in a noise signal with an amplitude of 0.2. The cross-correlation signal produced under these conditions is very clean, with an unambiguous peak located at the start point of the square-wave burst. Now try increasing the noise level to about 0.8, and decreasing the number of cycles to five. In this case, x1[n] is almost drowned in noise, and the cross-correlated signal includes many other peaks which are produced by the random effect of correlating the limited x1[n] sequence with the noise. To enhance the signal, simply increase the number of cycles in the tone burst, to perhaps 30.

Immediately, the genuine peak emerges from the noise floor, again corresponding in time to the start of the square-wave burst signal. Figure 5.10 shows signals before and after cross-correlation, generated by the program. In part (a) is shown a noisy tone burst, comprising a 10-cycle sine wave with a gain of 0.2, embedded in random noise with a range of±0.3. Part (b) depicts the cross-correlation of the original clean tone burst sequence with the noisy signal. Although the recovery is acceptable, it can be improved by increasing the duration of the tone burst. Parts (c) and (d) were

Sample number

0 2000 4000 6000 8000 10000

0 2000 4000 6000 8000 10000

0 2000 4000 6000 8000 10000 0 2000 4000 6000 8000 10000

0

Figure 5.10 Output from program Correlation.exe: (a) 10-cycle noisy tone burst;

(b) cross-correlation of (a) with original clean tone burst. Parts (c) and (d) are similar, but here a 20-cycle tone burst has been used

generated under the same conditions as part (a) and (b), with the difference that the tone burst consists of 20 cycles.

When cross-correlation is used in this manner, it is sometimes termed matched filtering, since we are trying to match our specimen signal with a version of itself in the received trace. If we time-reversed the signal x1[n], we could of course use the convolution equation to realise the cross-correlation operation. Therefore, we can state that for matched filters, the impulse response is given by

h[n] = x1[−n]. (5.22)

In this example, time reversal makes little difference since the wave shape has odd symmetry, that is, it is only inverted at its ends.

5.4.3 Temporal smearing and pseudo-random bit sequences

Although the above program demonstrates clearly the dramatic manner in which cross-correlation may enhance the SNR of a received tone burst signal, it also exposed a certain disadvantage with the method – that of temporal signal smearing. Our examination of auto-correlation revealed that the new sequence comprises M +N −1 values. Furthermore, because we are dealing with a tone burst, this tends to correlate with itself at intervals of 2π, gradually reaching a maximum when the displacement

between the two signal sequences is zero. So the original received signal is now smeared in time, sometimes making it difficult to locate its true start point. The longer the signal x1[n], the more severe this problem becomes. One way around this is to design a sequence x1[n] which only correlates well with itself when it is exactly in phase. Typically, we generate what is called a pseudo-random bit sequence, or PRBS.

Such signals are easily generated digitally, and even non-optimal systems can yield significant improvements over the standard square-wave tone burst employed in the program.

j:=0;

sa:=scrollbar1.Position;

edit1.Text:=inttostr(sa);

case sig_type.ItemIndex of 0: begin

N1:=50*sa;

for n:=0 to N1-1 do x1[n]:=0.2*sin(2*pi*n*sa/N1);

end;

1: begin

for m:=0 to sa do begin

if (random>0.5) then s:=0.2 else s:=-0.2;

for n:=0 to 20 do begin

x1[j]:=s;

inc(j);

end;

end;

N1:=j;

end;

end;

Listing 5.4

A random bit sequence can also be generated by Correlation.exe, simply by selecting the appropriate option from the Signal type group box. Listing 5.4 contains a fragment of code from the program that shows how both the tone burst and random sequence are generated. First, the signal type to be calculated is controlled by the value of sig_type.itemindex. The tone burst is straightforward; the variable satakes its value from the position of the scroll bar, and sets how many cycles of the sine wave are generated. In the case of the random bit sequence, the code always generates sa groups of bits, each of which is twenty signal values in length and either 0.2 or−0.2 in value (i.e. it is a bipolar bit sequence).

If you now use the program with the random sequence selected, you will see that the correlation peak is very sharp, indicating precisely the start location of the signal embedded in the noise. Even when the noise amplitude is high, we only need

2000 4000 6000 8000 Sample number

a b

0 10000

Magnitude Magnitude

20

10 15