48 SIGNALS AND SYSTEMS 6. INTEGRAL AND SUMMATION EVALUATION OF AUTO AND CROSS CORRELATION Correlation is a mathematical operation that, for time signals (continuous or discrete), can measure how 2 signals relate to each other. Correlation is similar to convolution, where as convolution describes how a linear system responds to a disturbance the correlation process has many applications. For example the correlation operation applied to response data from a system can be used to identify and characterize the system. This development applies to signals where the independent variable is mostly time but could also be frequency. Continuous Auto and Cross Correlation of Energy Signals An energy signal is one where the integral of its magnitude squared is finite and does not blow up. Given a time function f (t ) Equation 1 describes: f (t ) dt E 2 (1) The mathematical definition of the correlation of a time function x(t ) correlated with another time function y (t ) , where both are energy signals, denoted by x(t ) y(t ) is: rxy () x(t ) y(t ) x(t ) y(t )dt x(t ) y(t )dt (2) If a time function x(t ) is correlated with itself it becomes: rxx () x(t ) x(t ) x(t ) x(t )dt The second form of Equation 2 is also valid but unnecessary. Consider the Example 1 from the hand-out "Convolution Continuous and Discrete". Example 1: Given x(t ) e at u(t ) h(t ) u(t ) u(t T0 ) Find the continuous correlation of x and h rxy () x(t ) h(t ) = x(t )h(t )dt (3) 49 Figure 1 Continuous x and h functions for cross correlation In the convolution operation the product of the overlap between x and the shifted and flipped h is integrated or summed over with the variable of integration being and thus h(t ) is flipped causing it to go backwards. The variable time, t , is just a constant and is chosen to cover all possible cases of overlap between the 2 functions. In the correlation operation the variable t is the integration dummy variable and is the constant and thus h(t ) is not flipped. It is only delayed and does not go backwards. The variable , is just a constant and is chosen to cover all possible cases of overlap between the 2 functions. The default limits for the integral or sum are from minus infinity to infinity, but in fact the actual limits are obtained from an examination of the overlap obtained as the delayed function h(t ) is shifted over the domain of the other function x . Figure 2 illustrates the 2 functions prepared for correlation. Figure 3 illustrates selecting to obtain the 2 cases of overlap for this operation. Figure 2 functions x(t ), h(t ) prepared for correlation 50 Figure 3a Case 1 of x(t ) h(t ) Figure 3b Case 2 of x(t ) h(t ) Case 1 T0 0 rxy () T0 0 1 e dt e at a T at 1 e 0 a ( T ) a Case 2 0 rxy () T0 1 e dt e at a T at e a e a ( T ) a e a 1 e aT Case 1 must equal Case 2 at 0 , by inspection yep! Example 2 Auto-correlation of x(t ) from Example 1 Case 1 0 as seen in Figure 4. a 51 Figure 4 auto-correlation of x(t ) from Example 1, 0 rxx () e e at a ( t ) 0 ea 2 at dt e 2a 0 e a 2a Case 2 0 as seen in Figure 5. Figure 5 auto-correlation of x(t ) from Example 1, 0 rxx () e e at a ( t ) ea 2 at dt e 2a e a 2a Again, Case 1 must equal Case 2 at 0 and by inspection yep! Discrete Auto and Cross Correlation of Energy Signals The energy relationship for a discrete signal is given by Equation 4. f ( n) E 2 The cross correlation between 2 discrete energy functions x(n), y(n) is: (4) 52 rxy (k ) x ( n) y ( n k ) (5) n The auto-correlation of x(n) is: rxx (k ) x ( n) x ( n k ) (6) n The 2 summation identities that are used to obtain closed form expressions from Equations 5 and 6 are given in Equation 7 n n 0 1 , 1, 1 N 1 n n 0 1 N , 1 1 We evaluate the discrete form of Examples 1 and 2. The discrete energy functions that are to be auto and cross correlated are given in Figure 4. Figure 4 discrete energy functions x(n), h(n) Example 3 Cross correlation of x(n), h(n) Given: x(n) n u(n) and y(n) u(n) u(n T0 ) Note that at n T0 , y(n) 0 . Case 1 1 T0 k 0 Figure 5 illustrates Case 1: (7) 53 Figure 5 Case 1 overlap for Example 3 rxy (k ) k T0 1 n n 0 1 k T0 1 Case 2 k 0 Figure 6 illustrates Case 2 overlap: Figure 6 Case 2 overlap for Example 3 rxy (k ) k T0 1 nk n k T0 1 n 0 1 k T0 1 k k k T0 1 1 1 n 0 k 1 n n Again, Case 1 must equal Case 2 at k 0 and: Case 1 = Case 2 = rxy (0) Example 4 1 T0 , yep! 1 54 Auto-correlation of x(n) n u(n) from Figure 4 Case 1 k 0 Figure 7 illustrates Case 1: Figure 7 Case 1 for Example 4 rxx (k ) n ( nk ) k n 0 n 0 2n k n 0 2 n 1 k 1 2 1 2 k Case 2 k 0 Figure 8 illustrates Case 2 Figure 8 Case 2 for Example 4 k 1 n n 2k k rxx (k ) n ( n k ) k 2 n k 2 2 k 1 2 1 2 nk nk n 0 n 0 Now at k 0 Case1 must equal Case 2 and by inspection yep! Auto and Cross Correlation of Continuous Periodic Signals 55 Periodic signals are not energy signals they are power signals and thus the integrals of Equations 2 & 3 and the summations of Equations 5 & 6 become: For 2 periodic continuous functions x(t ), y(t ) with period T the cross correlation is: rxy () x(t ) y(t ) 1 1 x(t ) y(t )dt x(t ) y (t )dt T T T T (8) The autocorrelation of the periodic function x(t ) with period T is: rxx () x(t ) x(t ) 1 1 x(t ) x(t )dt x(t ) x(t )dt T T T T (9) To evaluate Equation 8 or Equation 9 one must take one period (and only one period) of the delayed signal and slide it across the un-delayed signal sweeping over a whole period at the evaluators convenience. For example if the period is T one could sweep from 0 to T or from T to T etc and……integrate everything that overlaps with the un-delayed 2 2 signal even if it's in different periods of the un-delayed signal. Clearly there could be multiple cases. Because of the complexity of this operation the evaluator should carefully sketch the waveforms and determine all of the overlap scenarios with the associated limits of integration. Additionally, as with energy signals at the boundaries between cases the different expressions for each case must become the same. Let's do a simple example of an auto-correlation. Example 5 Consider the periodic unit amplitude pulse waveform of Figure 9. Figure 9 periodic unit amplitude pulse waveform 56 Figure 10 illustrates the signal prepared for correlation. Case 1 0 and T T which becomes: 0 T (1 ) 1 rxx () T T dt T Case 2 T T and T which becomes: T (1 ) T rxx () 1 T T dt 1 T T T dt 1 T T T (2 1) T Case 3 T and T which becomes: T T T 1 1 rxx () dt T T ( 1) T T T T For the results to be valid Case 1 rxx ( T (1 )) must equal Case 2 rxx ( T (1 )) Case 1 rxx ( T (1 )) 2 1 T T (1 ) Case 2 rxx ( T (1 )) 2 1 , Case 1 = Case 2 at boundary, OK Also Case 2 rxx ( T ) must equal Case 3 rxx ( T ) Case 2 rxx ( T ) 2 1 57 Case 3 rxx ( T ) 1 T 2 1 , Case 2 = Case 3 at boundary, OK T Finally, Case 3 rxx ( T ) must equal Case 1 rxx ( 0) because rxx is a periodic function. Case 3 rxx ( T ) 1 T T Case 1 rxx ( 0) T T (1 ) Case 1 = Case 3 at boundary, OK A sketch of the result rxx () is shown in Figure 11 Figure 11 sketch periodic rxx () Auto and Cross Correlation of Discrete Periodic Signals Periodic signals are not energy signals they are power signals and thus the summations of Equations 5 & 6 become: For 2 periodic discrete functions x(n), y(n) with period N the cross correlation is: rxy (k ) x(n) y (n) 1 N 1 x ( n) y ( n k ) N x ( n k ) y ( n ) N (10) N The autocorrelation of the periodic function x(n) with period N is: rxx (k ) x(n) x(n) 1 N 1 x ( n) x ( n k ) N x ( n k ) x ( n ) N (11) N To evaluate Equation 10 or Equation 11 one must take one period (and only one period) of the delayed signal and slide it across the un-delayed signal sweeping over a whole period at the evaluators convenience. For example if the period is N one could sweep 58 from 0 to N or from N to N etc and……summing everything that overlaps with 2 2 the un-delayed signal even if it's in different periods of the un-delayed signal. Clearly there could be multiple cases. Because of the complexity of this operation the evaluator should carefully sketch the waveforms and determine all of the overlap scenarios with the associated limits of summation. Additionally, as with energy signals at the boundaries between cases the different expressions for each case must become the same. Let's do a simple example of an auto-correlation. Example 6 Consider the periodic unit amplitude pulse waveform of Figure 12. Figure 12 a periodic discrete unit pulse for auto correlation An issue that must be addressed with discrete functions is that at the point of discontinuity n 0, n N , n N the function must have a value. In the continuous world a function can instantly jump between 2 values. In the discrete world that can't happen. For this example we define at the start of the pulse it is at its unit amplitude and at the end of the pulse it is at zero. Figure 13 illustrates the pulse train ready for examination of cases for auto correlation. Figure 13 sketch of auto correlation scenario for x(n) The discontinuity assumption for one period of x(n) is given as: 0 n N 1, x ( n) 0, N n N As with the continuous example of periodic auto correlation, when the delay integer k sweeps over the period N of x(n) several cases of overlap will occur. Case 1: k 0 and k N 1 N , this becomes: 0 k N (1 ) 1 and thus: 59 1 rxx (k ) N N 1 1 k 1 N N 1 k 1 N nk Case 2: k N and k N 1 N , this becomes: N 1 1 k N and thus: rxx (k ) 1 N 1 k N 1 1 1 1 1 N 1 k 1 k N 1 N 1 2 1 N nk N n N N Case 3: k N 1 and k N , which becomes: N k N and thus: rxx (k ) 1 N k N 1 n N 1 1 k k N 1 1 N 1 N N Summarizing: k N Case 2: N 1 1 k N ; rxx (k ) 2 1 Case 1: 0 k N (1 ) 1; rxx (k ) Case 3: N k N ; rxx (k ) k 1 N Now checking consistency between boundaries: Case 1 rxx (0) Case 3 rxx ( N ) , yep Case 1 rxx ( N 1 ) Case 2 rxx ( N 1 1) 2 1 , yep Case 2 rxx (N 1) Case 3 rxx (N ) 2 1, yep Figure 14 gives a sketch of the discrete auto correlation of the periodic function x(n) Figure 14 discrete cross correlation function for x(n)