Click here to purchase the entire book in PDF format.



next up previous contents index
Next: The math Up: Convolution, Correlation and Coherence Previous: The math   Contents   Index

Autocorrelation

If you have a random number that lies in the range of -1 to 1 and you multiply it by a random number that lies in the same range, you'll get a random number that lies in the same range. As we saw in Section 4.16, the result of the multiplication will have a different probability distribution function, but we'll ignore that for now. The point for now is that a random number times a random number equals a random number.

If you now take a random number that lies in the range of -1 to 1 and multiply it by itself. you'll get a positive number. Again, we'll ignore the probability distribution function of the result. The point is that a random number squared is positive.

Let's think back to the process of real convolution with the example of convolving an audio signal with the impulse response of a room. The first sample of the signal is multiplied by the first tap (sample) in the impulse response first. The two signals (the audio signal and the impulse response) move through each other until the last sample of the audio signal is multiplied by the last tap in the impulse response. This is conceptually represented in Figure 9.60.

Figure 9.60: A block diagram of the concept of convolution. Notice that one of the signals is time-reversed.
\includegraphics[width=2.75in]{09dsp/graphics/convolution_blockdiagram}

Notice in that figure that the two signals are opposite each other - in other words, the audio signal in the diagram reads start to end from right to left while the impulse response reads from left to right.

What would happen if we did exactly the same math, but we didn't time-reverse one of the signals? This idea is shown in Figure 9.61.

Figure 9.61: A block diagram of a process similar to convolution, but it's not. Notice that neither of the signals is time-reversed.
\includegraphics[width=2.75in]{09dsp/graphics/correlation_blockdiagram}

You may be asking yourself what use this could possibly be. A fair question. Let's have a look at an example. We'll start by looking at a series of 16 completely random numbers, shown in Figure 9.62. If I were a statistician or a mathematician, I would say that these were random numbers. If I were a recording engineer, I would call it white noise.

Figure 9.62:
\includegraphics[width=2.75in]{09dsp/graphics/random_for_autocorr}

Let' s take that signal, and put it thought the process shown in Figure 9.61. Instead of using two different signals, we're going to use the same signal for both. So, we start as in Figure 9.63, with the two signals lined up, ready to multiply by each other. In this case, we're multiplying each sample by its corresponding sample (see the caption). We then add all the results of the multiplications and we get a result. In this case, since all the multiplications resulted in 0, the sum of all 32 zero's is 0.

Figure 9.63: The top graph shows the original noise signal from Figure 9.62. The middle graph shows the same signal, but offset in time. We multiply sample 1 from the top graph by sample 1 from the middle graph and the result is sample 1 in the bottom graph. We then add all the values in the bottom graph to each other, and the result is 0.
\includegraphics[width=2.75in]{09dsp/graphics/autocorr_01}

Once we get that result, we shift the two signals closer together by one sample and repeat the whole process, as is shown in Figure 9.64.

Figure 9.64: The same two signals as in Figure 9.63, moved closer together by one sample. After these are multiplied, sample by sample, and all the results are added together, the result in this particular case will be 0.15.
\includegraphics[width=2.75in]{09dsp/graphics/autocorr_02}

Then we move the signals by one sample and do it again, as is shown in Figure 9.65.

Figure 9.65: The process again, with the signals moved by one sample. The result of this addition is 0.32.
\includegraphics[width=2.75in]{09dsp/graphics/autocorr_03}

We keep doing this over and over, each time, moving the two signals by one sample and adding the results of the multiplications. Eventually, we get to a point where the signals are almost aligned as in Figure 9.66.

Figure 9.66: The process again, after the signals have been moved until they're almost aligned. The result of this addition is -0.02.
\includegraphics[width=2.75in]{09dsp/graphics/autocorr_15}

Then we get to a point in the process where an important thing happens. the two signals are aligned, as can be seen in Figure 9.67. Up until now, the output from each set of multiplications and additions has resulted in a fairly small number, as we've seen (the list of all the values that I haven't shown will be given later...). This is because we're multiplying random numbers that might be either positive or negative, result in numbers that might be either positive or negative, and adding them all together. (If the two signals are very long, and completely random, the result will be 0.) However, when the two signals are aligned, the result of all the individual multiplications will be positive (because any number other than 0, when multiplied by itself, gives a positive result).

If the signals are very long and random, not only will we get a result very close to zero for all other alignments, we'll get a very big number for this middle alignment. The longer the signals, the bigger the number will be.

Figure 9.67: The process again, when the signals have been aligned. The result of this addition is 2.18. Notice that this is a much bigger number than the other ones we've seen.
\includegraphics[width=2.75in]{09dsp/graphics/autocorr_16}

We keep going with the procedure, moving the signals one sample in the same direction and repeating the process, as is shown in Figure 9.68. Notice that this looks very similar to the alignment shown in Figure 9.66. In fact, the two are identical, it's just that the top and middle graphs have swapped places, in effect. As expected, the result of the addition will be identical in the two cases.

Figure 9.68: The process again, after the signals have been moved one sample past the point where they are aligned. The result of this addition is -0.02.
\includegraphics[width=2.75in]{09dsp/graphics/autocorr_17}

The process continues, providing a symmetrical set of results, until the two signals have moved apart from each other, resulting in a zero again, just as we saw in the beginning.

If we actually do this process for the set of numbers initially shown in Figure 9.62, we get the following set of numbers: 0.15, 0.32, -0.02, -0.20, 0.08, -0.12, 0.01, 0.43, -0.11, 0.38, 0.02, -0.59, 0.24, -0.35, -0.02, 2.18, -0.02, -0.35, 0.24, -0.59, 0.02, 0.38, -0.11, 0.43, 0.01, -0.12, 0.08, -0.20, -0.02, 0.32, 0.15. If we then take these numbers and graph them, we get the plot shown in Figure 9.69.

Figure 9.69: The result of the multiplications and additions for the whole process using the signal shown above. There are two things to notice. First, that the resulting signal is symmetrical. Second, that there is a big spike right in the middle - the result of when the two signals were aligned.
\includegraphics[width=2.75in]{09dsp/graphics/autocorr_result}

The result of this whole thing actually gives us some information. Take a look at Figure 9.69, and you'll see three important characteristics. Firstly, the signal is symmetrical. This doesn't tell us much, other than that the signals that went through the procedure were the same. Secondly, most of the values are close to zero. This tells us that the signals were random. Thirdly, there's a big spike in the middle of the graph, which tells us that the signals lined up and matched each other at some point.

What we have done is a procedure called autocorrelation - in other words, we're measuring how well the signal is related (or co-related, to be precise) to itself. This may sound like a silly thing to ask - of course a signal is related to itself, right? Well, actually, no. We saw above that, unless the signals are aligned, the result of the multiplications and additions are 0. This meant that, unless the signal was aligned with itself, it is unrelated to itself (because it is noise).

What would happen if the we did the same thing, except that our original signal was periodic instead of noise? Take a look at Figure 9.70. Notice that the output of the autocorrelation still has a big peak in the middle - essentially telling us that the signal is very similar (if not identical) to itself. But you'll also notice that the output of the autocorrelation looks sort of periodic. It's a sinusoidal wave with an envelope. Why is this? It's because the original signal is periodic. As the we move the signal through itself in the autocorrelation process, the output tells us that the signal is similar to itself when it's shifted in time. So, for example, the first wave in the signal is identical to the last wave in the signal. Therefore a periodic component in the output of the autocorrelation tells us that the signal being autocorrelated is periodic - or at least that it has a periodic component.

Figure 9.70: The top plot is the signal. The bottom is the result of the autocorrelation of the signal.
\includegraphics[width=2.75in]{09dsp/graphics/autocorr_periodic_example}

So, autocorrelation can tell us whether a signal has periodic components. If the autocorrelation has periodic components, then the signal must as well. If the autocorrelation does not, and is just low random numbers, with a spike in the middle, then the signal does not have any periodic components.



Subsections
next up previous contents index
Next: The math Up: Convolution, Correlation and Coherence Previous: The math   Contents   Index
Geoff Martin 2006-10-15

Click here to purchase the entire book in PDF format.