App. Phys. 602 : Digital Signal Processing Topic 2: Time domain 602 - Digital Signal Processing, Semester VIII 9/27/2022 1 Discrete-time systems Convolution Linear Constant-Coefficient Difference Equations (LCCDEs) Correlation
1. Discrete-time systems A system converts input to output: E.g. Moving Average (MA): x [ n ] DT System y [ n ] ( M = 3) x [ n ] y [ n ] + z -1 z -1 1/ M 1/ M 1/ M x [ n -1] x [ n -2] y [ n ] 1 M x [ n k ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 2 k M 1 { y [ n ]} = f ({ x [ n ]}) n A
Moving A verage (MA) x [ n ] y [ n ] + z -1 z -1 1/ M 1/ M 1/ M x [ n -1] x [ n -2] n x [ n ] 1 2 3 4 5 6 7 8 9 A n -1 x [ n -1] 1 2 3 4 5 6 7 8 9 -1 x [ n -2] -1 1 2 3 4 5 6 7 8 9 n 1 2 3 4 5 6 7 8 9 n y [ n ] -1 y [ n ] 1 M x [ n k ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 3 k M 1
MA Smoother MA smoothes out rapid variations (e.g. “12 month moving average”) e.g. signal noise 5 k y [ n ] 1 4 x [ n k ] 5-pt moving average x [ n ] = s [ n ] + d [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 4
Accumulator Output accumulates all past inputs: x [ n ] y [ n ] + z -1 602 - Digital Signal Processing, Semester VIII 9/27/2022 5 y [ n -1] n y [ n ] x [ ] n 1 x [ ] x [ n ] y [ n 1 ] x [ n ]
Accumulator n x [ n ] -1 1 2 3 4 5 6 7 8 9 A y [ n -1] -1 1 2 3 4 5 6 7 8 9 n 1 2 3 4 5 6 7 8 9 n y [ n ] -1 x [ n ] y [ n ] + z -1 602 - Digital Signal Processing, Semester VIII 9/27/2022 6 y [ n -1]
Classes of DT systems Linear systems obey superposition : if input x 1 [ n ] → output y 1 [ n ] , x 2 → y 2 ... given a linear combination of inputs : then output for all , , x 1 x 2 i.e. same linear combination of outputs x [ n ] DT system y [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 7
Lineari t y: Example 1 Accumulator: Linear 602 - Digital Signal Processing, Semester VIII 9/27/2022 8 n y [ n ] x [ ] n y [ n ] x 1 [ ] x 2 [ ] x 1 [ ] x 2 [ ] x 1 [ ] x 2 [ ] y 1 [ n ] y 2 [ n ] x [ n ] x 1 [ n ] x 2 [ n ]
Lineari t y Example 2: “Teager Energy operator”: y [ n ] x 2 [ n ] x [ n 1 ] x [ n 1 ] x [ n ] x 1 [ n ] x 2 [ n ] Nonlinear 602 - Digital Signal Processing, Semester VIII 9/27/2022 9 y [ n ] 1 2 x [ n ] x [ n ] 2 x 1 [ n 1 ] x 2 [ n 1 ] x 1 [ n 1 ] x 2 [ n 1 ] y 1 [ n ] y 2 [ n ]
Lineari t y Example 3: ‘Offset’ accumulator: but Nonlinear 602 - Digital Signal Processing, Semester VIII 9/27/2022 10 .. unless C = n y [ n ] C x [ ] n y 1 [ n ] C x 1 [ ] n y [ n ] C x 1 [ ] x 2 [ ] y 1 [ n ] y 2 [ n ]
Property: Shift (time) invariance 602 - Digital Signal Processing, Semester VIII 9/27/2022 11 Time-shift of input causes same shift in output i.e. if x 1 [ n ] → y 1 [ n ] the n x [ n ] x 1 [ n n ] y [ n ] y 1 [ n n ] i.e. process doesn’t depend on absolute value of n
Shift-invariance counterexample Upsampler: L Not shift invariant y [ n ] = x [ n/ L ] n = , ± L, ± 2 L , . . . otherwise ( n = r · L ) y 1 [ n ] = x 1 [ n/L ] x [ n ] = x 1 [ n - n ] =} y [ n ] = x [ n/L ] = x 1 [ n/L - n ] = x 1 n - L · n L 602 - Digital Signal Processing, Semester VIII 9/27/2022 12 = y 1 [ n - L · n ] = 1 / y [ n - n ] x [ n y [ n ] {
Another counterexample Hence If then Not shift invariant - parameters depend on n ≠ y [ n ] n x [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 13 scaling by time index y 1 [ n n ] n n x 1 [ n n ] x [ n ] x 1 [ n n ] y [ n ] n x 1 [ n n ]
Linear Shift Invariant ( LSI ) 602 - Digital Signal Processing, Semester VIII 9/27/2022 14 Systems which are both linear and shift invariant are easily manipulated mathematically This is still a wide and useful class of systems If discrete index corresponds to time, called Linear Time Invariant (LTI)
Causality If output depends only on past and current inputs (not future), system is called causal Formally, if x 1 [ n ] → y 1 [ n ] & x 2 [ n ] → y 2 [ n ] Causa l x 1 [ n ] x 2 [ n ] n N y 1 [ n ] y 2 [ n ] n N 602 - Digital Signal Processing, Semester VIII 9/27/2022 15
Causality example Moving average: y [ n ] y [ n ] depends on x [ n - k ] , k ≥ → causal ‘Centered’ moving average .. looks forward in time → noncausal .. Can make causal by delaying 1 M x [ n k ] k M 1 c y n y n M 1 / 2 1 M x [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 16 x [ n k ] x [ n k ] ( M 1 ) / 2 k 1
602 - Digital Signal Processing, Semester VIII 9/27/2022 17
Impulse response (IR) Impulse (unit sample sequence) Given a system: if x [ n ] = [ n ] then “impulse response” LSI system completely specified by h [ n ] n 1 2 3 4 5 6 7 [ n ] 1 -3 -2 -1 x [ n ] DT system y [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 18 Y[n]
Impulse response example Simple system: α x [ n ] y [ n ] + z -1 z -1 α 2 α 3 n 1 2 3 4 5 6 7 x [ n ] 1 -3 -2 -1 n y [ n ] 1 2 3 4 5 6 7 α -3 -2 -1 α α x [ n ] [ n ] impulse y [ n ] = h [ n ] impulse response 602 - Digital Signal Processing, Semester VIII 9/27/2022 19
2. Convolution Impulse response: Shift invariance: + Linearity: Can express any sequence with s: x [ n ] = x [0] [ n ] + x [1] [ n -1] + x [2] [ n -2] .. [ n ] LSI h [ n ] [ n-n ] LSI h [ n-n ] α · [ n-k ] + β · [ n-l ] LSI α · h [ n-k ] + β · h [ n-l ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 20
602 - Digital Signal Processing, Semester VIII 9/27/2022 21
602 - Digital Signal Processing, Semester VIII 9/27/2022 22
Convolu t ion sum Hence, since C on v olu t io n sum x [ n ] x [ k ] [ n k ] k k F or LS I , y [ n ] x [ k ] h [ n k ] wri tt en as y [ n ] x [ n ] * h [ n ] Summation is symmetric in x and h i.e. l = n – k → l x [ n ] * h [ n ] x [ n l ] h [ l ] h [ n ] * x [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 23
Convolution properties LSI System output y [ n ] = input x [ n ] convolved with impulse response h [ n ] → h [ n ] completely describes system Commutative: x [ n ] * h [ n ] = h [ n ] * x [ n ] Associative: ( x [ n ] * h [ n ]) * y [ n ] = x [ n ] * ( h [ n ] * y [ n ]) Distributive: h [ n ] * ( x [ n ] + y [ n ] ) = h [ n ] * x [ n ] + h [ n ] * y [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 24
Interpreting convolution Passing a signal through a (LSI) system is equivalent to convolving it with the system’s impulse response x [ n ] h [ n ] y [ n ] = x [ n ] ∗ h [ n ] x [ n ]={0 3 1 2 -1} h [ n ] = {3 2 1} n 1 2 3 4 5 6 7 -3 -2 -1 n 1 2 3 5 6 7 -3 -2 -1 y [ n ] x [ k ] h [ n k ] h [ k ] x [ n k ] k k 602 - Digital Signal Processing, Semester VIII 9/27/2022 25 → →
Convolu t ion in t erpre t a t ion 1 Time-reverse h , shift by n , take inner product against fixed x k 1 2 3 5 6 7 -3 -2 -1 x [ k ] k 1 2 3 4 5 6 7 -3 -2 -1 h [0- k ] k 1 2 3 4 5 6 7 -3 -2 -1 k 1 2 3 4 5 6 7 -3 -2 -1 h [2- k ] n 1 2 3 5 7 -3 -2 -1 y [ n ] 9 9 11 2 -1 k 602 - Digital Signal Processing, Semester VIII 9/27/2022 26 y [ n ] x [ k ] h [ n k ] =g [ k ] h [1- k ] =g [ k -1] call h [- n ] = g [ n ]
Convolu t ion in t erpre t a t ion 2 Shifted x ’s weighted by points in h Conversely, weighted, delayed versions of h ... n 1 2 3 5 7 -3 -2 -1 y [ n ] 9 9 11 2 -1 n 1 2 3 5 6 7 -3 -2 -1 x [ n ] n 1 2 3 4 6 7 -3 -2 -1 x [ n -1] n 1 2 3 4 5 7 -3 -2 -1 x [ n -2] k 1 2 3 4 5 6 7 h [ k ] -3 -2 -1 602 - Digital Signal Processing, Semester VIII 9/27/2022 27 y [ n ] h [ k ] x [ n k ] k
Matrix interpretation 602 - Digital Signal Processing, Semester VIII 9/27/2022 28 Diagonals in X matrix are equal
Convolu t ion no t es 602 - Digital Signal Processing, Semester VIII 9/27/2022 29 Total nonzero length of convolving N and M point sequences is N + M -1 Adding the indices of the terms within the summation gives n : k i.e. summation indices move in opposite senses y [ n ] h [ k ] x [ n k ] k n k n
Convolution in MATLAB 602 - Digital Signal Processing, Semester VIII 9/27/2022 30 T he M- f ile conv implemen t s t he convolution sum of two finite-length sequences If a [ b [ 3 3 1 2 - 1 ] 2 1 ] the n conv(a,b) yields [ 9 9 11 2 - 1 ]
Connected systems Cascade connection: Impulse response h [ n ] of the cascade of two systems with impulse responses h 1 [ n ] and h 2 [ n ] is By commutativity, * h [ n ] h 1 [ n ] ⊛ 602 - Digital Signal Processing, Semester VIII 9/27/2022 31
602 - Digital Signal Processing, Semester VIII 9/27/2022 32
Inverse systems [ n ] is identity for convolution i.e . x [ n ] * [ n ] x [ n ] Consider x [ n ] y [ n ] z [ n ] z [ n ] h 2 [ n ] * y [ n ] h 2 [ n ] * h 1 [ n ] * x [ n ] x [ n ] i f h 2 [ n ] * h 1 [ n ] [ n ] h 2 [ n ] is the inverse system of h 1 [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 33
Inverse systems Use inverse system to recover input x [ n ] from output y [ n ] (e.g. to undo effects of transmission channel) Only sometimes possible - e.g. cannot ‘invert’ h 1 [ n ] = 0 In general, attempt to solve h 2 [ n ] * h 1 [ n ] [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 34
Inverse system example Accumulator: Impulse response h 1 [ n ] = μ [ n ] Thus, ‘backwards difference’ is inverse system of accumulator. ‘Backwards difference’ .. has desired property: [ n ] [ n 1 ] [ n ] n -3 -2 -1 1 2 3 4 5 6 7 n -3 -2 -1 1 2 3 4 5 6 7 602 - Digital Signal Processing, Semester VIII 9/27/2022 35
Parallel connection Impulse response of two parallel systems added together is: 602 - Digital Signal Processing, Semester VIII 9/27/2022 36
3. Linear Constant-Coefficient Difference Equation (LCCDE) General spec. of DT, LSI, finite-dim sys: Rearrange for y [ n ] in causal form: WLOG, always have d = 1 defined by { d k },{ p k } order = max( N , M ) k k N M d k y [ n k ] p k x [ n k ] k y [ n ] d p k k 1 d k d 602 - Digital Signal Processing, Semester VIII 9/27/2022 37 N M y [ n k ] x [ n k ]
602 - Digital Signal Processing, Semester VIII 9/27/2022 38
Solving LCCDEs “Total solution” y [ n ] y c [ n ] y p [ n ] Complementary Solution N satisfies Particular Solution for given forcing function x [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 39 d k y [ n k ] k
Complementary Solution 602 - Digital Signal Processing, Semester VIII 9/27/2022 40 General form of unforced oscillation i.e. system’s ‘natural modes’ Characteristic polynomial of system - depends only on { d k } y c [ n ] n k d n k k Assume y c has form N n N N 1 d d N 1 ... d N 1 N d k d N k N k
Complementary Solution 602 - Digital Signal Processing, Semester VIII 9/27/2022 41 i factors into roots λ , i.e. Each/any λ i satisfies eqn. Thus, complementary solution: Any linear combination will work → α i s are free to match initial conditions k d N k N k 1 2 ( ) ( )... y [ n ] c 1 1 2 2 3 3 n n n ...
Complementary Solution Repeated roots in chr. poly: Complex λ i s → sinusoidal y c [ n ] i i n y [ n ] c 1 1 n n n 2 n 2 1 3 1 ... n L 1 n ... L 1 1 2 n ( ) L ( )... 602 - Digital Signal Processing, Semester VIII 9/27/2022 42
Particular Solution 602 - Digital Signal Processing, Semester VIII 9/27/2022 43 Recall: Total solution Particular solution reflects input ‘Modes’ usually decay away for large n leaving just y p [ n ] Assume ‘form’ of x [ n ] , scaled by β : e.g. x [ n ] constant → y p [ n ] = β x [ n ] = λ → y [ n ] = β · λ p n n ( λ ∉ λ i ) or = β n L λ n ( λ ∈ λ i ) y [ n ] y c [ n ] y p [ n ]
LCCDE example Need input : x [ n ] = 8 μ [ n ] Need initial conditions : y [-1] = 1, y [-2] = -1 y [ n ] y [ n 1 ] 6 y [ n 2 ] x [ n ] x [ n ] + y [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 44
LCCDE example 602 - Digital Signal Processing, Semester VIII 9/27/2022 45 Complementary solution: y [ n ] y [ n 1 ] 6 y [ n 2 ] ; 3 2 → roots λ = -3, λ = 2 1 2 y c [ n ] 1 3 2 2 n n α 1 , α 2 are unknown at this point y [ n ] n n 2 2 6
LCCDE example 602 - Digital Signal Processing, Semester VIII 9/27/2022 46 Particular solution: Input x [ n ] is constant = 8 μ [ n ] assume y p [ n ] = β , substitute in: y [ n ] y [ n 1 ] 6 y [ n 2 ] x [ n ] 6 8 [ n ] 4 8 2 (‘large’ n )
Solve for unknown α i s by substituting n = LCCDE example from ICs initial conditions into DE at n = 0, 1, ... y [ n ] y [ n 1 ] 6 y [ n 2 ] x [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 47 1 2 n n 3 2 T o t al solu t ion y [ n ] y c [ n ] y p [ n ] y [ ] y [ 1 ] 6 y [ 2 ] x [ ] 1 6 8 1 2 3 1 2
LCCDE example n = 1 Don’t find α i s by solving with ICs at n = -1,-2 (ICs may not reflect natural modes; Mitra3 ex 2.37-8 (4.22-3) is wrong ) 602 - Digital Signal Processing, Semester VIII 9/27/2022 48 y [ 1 ] y [ ] 6 y [ 1 ] x [ 1 ] ( 3 ) ( 2 ) 6 8 1 2 1 2 1 2 2 3 18 solve: α 1 = -1.8 , α 2 = 4.8 Hence, system output: y [ n ] 1.8( 3) n 4.8(2) n 2 n
LCCDE solving summary 602 - Digital Signal Processing, Semester VIII 9/27/2022 49 Difference Equation (DE): Ay [ n ] + By [ n -1] + ... = Cx [ n ] + Dx [ n -1] + ... Initial Conditions (ICs): y [-1] = ... DE RHS = with y [ n ]= λ n → roots { λ i } gives complementary soln Particular soln : y p [ n ] ~ x [ n ] solve for βλ n “at large n ” α i s by substituting DE at n = 0, 1, ... ICs for y [-1], y [-2]; y t = y c + y p for y [0], y [1] c y [ n ] i i n
LCCDEs: zero input/zero state 602 - Digital Signal Processing, Semester VIII 9/27/2022 50 Alternative approach to solving LCCDEs is to solve two subproblems: y zi [ n ] , response with zero input (just ICs) y zs [ n ] , response with zero state (just x [ n ] ) Because of linearity, y [ n ] = y zi [ n ]+ y zs [ n ] Both subproblems are ‘fully realized’ But, have to solve for α i s twice (then sum them)
Impulse response of LCCDEs Impulse response: i.e. solve with x [ n ] = δ [ n ] → y [ n ] = h [ n ] (zero ICs) With x [ n ] = δ [ n ] , ‘form’ of y p [ n ] = βδ [ n ] → solve y [ n ] for n = 0,1, 2... to find α i s δ [ n ] LCCDE h [ n ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 51
LCCDE I R example t hus 1 602 - Digital Signal Processing, Semester VIII 9/27/2022 52 n ≥ Infinite length e.g. y [ n ] y [ n 1 ] 6 y [ n 2 ] x [ n ] (from before); x [ n ] = δ [ n ]; y [ n ] = 0 for n <0 y [ n ] c 1 2 3 2 n n h [ n ] 0. 6 3 n 0. 4 2 n y p [ n ] = βδ [ n ] n = 0: y [ ] y [ 1 ] 6 y [ 2 ] x [ ] α 1 + α 2 + β = 1 n = 1: α 1 (–3) + α 2 (2) + 1 = n = 2: α 1 (9) + α 2 (4) – 1 – 6 = α 1 = 0.6, α 2 = 0.4, β =
System property: Stability Output grows without limit in some conditions z -1 2 n Certain systems can be unstable e.g. x [ n ] + y [ n ] y [ n ] -1 1 2 3 4 ... 602 - Digital Signal Processing, Semester VIII 9/27/2022 53
Stability Several definitions for stability; we use Bounded-input, bounded-output (BIBO) stable For every bounded input x [ n ] B x n output is also subject to a finite bound, y [ n ] B y n 602 - Digital Signal Processing, Semester VIII 9/27/2022 54
Stability example MA f il t er: → BIBO Stable M k y [ n ] 1 M 1 x [ n k ] M k y [ n ] 1 M 1 x [ n k ] M k 1 M 1 x [ n k ] M 1 M B B 602 - Digital Signal Processing, Semester VIII 9/27/2022 55 x y
S t abili t y & LCCDEs 602 - Digital Signal Processing, Semester VIII 9/27/2022 56 LCCDE output is of form: y [ n ] n n ... n 1 1 2 2 0 α s and β s depend on input & ICs, but to be bounded for any input we need |λ ...
4. Correlation Correlation ~ identifies similarity between sequences: Cross of x against y “lag” correla t ion 602 - Digital Signal Processing, Semester VIII 9/27/2022 57 Note: Set m = n-l
Correlation and convolution 602 - Digital Signal Processing, Semester VIII 9/27/2022 58 Correlation: Convolu t ion: Hence: Correlation may be calculated by convolving with time-reversed sequence
Autocorrelation 602 - Digital Signal Processing, Semester VIII 9/27/2022 59 Energy of sequence x [ n ] xx Note : r [ ] 2 n x [ n ] x Autocorrelation (AC) is correlation of signal with itself:
Correla t ion maxima Note: From geometry, when x // y , cos θ = 1 , else cos θ < 1 angle between x and y r x x [ ] r x x [ ] r x x [ ] r x x [ ] 1 xy Similarly: r [ ] x y r x y [ ] r x x [ ] r y y [ ] 1 i xy x i y i x y cos x i 2 602 - Digital Signal Processing, Semester VIII 9/27/2022 60
AC of a periodic sequence Sequence of period N : x ˜ [ n ] x ˜ [ n N ] Calculate AC over a finite window: if M >> N r x ˜ x ˜ [ ] 1 2 M 1 n M M x ˜ [ n ] x ˜ [ n ] 1 N n N 1 602 - Digital Signal Processing, Semester VIII 9/27/2022 61 x ˜ [ n ] x ˜ [ n ]
AC of a periodic sequence i.e AC of periodic sequence is periodic Average energy per sample or Power of x x ˜ x ˜ r [ ] 1 N 2 x ˜ [ n ] P N 1 n x ˜ r x ˜ x ˜ [ N ] 1 N n N 1 602 - Digital Signal Processing, Semester VIII 9/27/2022 62 x ˜ [ n ] x ˜ [ n N ] r x ˜ x ˜ [ ]
Cross correlation r x y [ ] What correlations look like AC of any x [ n ] AC of periodic r x x [ ] 602 - Digital Signal Processing, Semester VIII 9/27/2022 63 r x ˜ x ˜ [ ]
What correlation looks like 602 - Digital Signal Processing, Semester VIII 9/27/2022 64