<<

ESS 522 2014

9. Finite Filters and the Z-transform

We are going to have two lectures on filters – you can find much more material in Bob Crosson’s notes. In the first lecture we will focus on some of the theory underlying filters, which are also known as finite impulse response (FIR) filters. In the second lecture, we will discuss the practical aspects of filtering.

Filtering in the

In Lecture 3 on Linear Systems and Convolution, we introduced the idea of linear systems or linear filters. We can write the filtering operation in the time domain symbolically in terms of an operator L as x(t) ! [L] ! y(t) or y(t) = L[x(t)] (9-1) We can characterize a filter by measuring its response to a delta function ! (t) " [L] " g(t) (9-2) The response of the filter to any other input is a convolution of the input and the impulse response of the filter x(t) ! [L] ! g(t)* x(t) (9-3)

If we extend this to the discrete domain we get the same result. If we define a discrete delta function as ! =1 k = 0 k (9-4) = 0 k ! 0 then

! k " L " gk (9-5) and the output yk for input sequence xk is given by a discrete convolution N!1 y g x (9-6) k = " l k!l l=0 A filter of the type gk that is applied by a convolution is termed a finite impulse response filter.

Z-transform

To understand how filters work we will introduce the Z-transform. If we consider a sequence bj = [b0, b1, … bN-1] where samples with negative indices are zero and the index 0 corresponds to time zeros, then the Z transform of bj is given by N%1 Z !b # B z b z0 b z1 b z2 ... b z(N%1) b z j (9-7) " j $ = ( ) = 0 + 1 + 2 + + N%1 = & k j=0 where z is a .

If we set 2"ik z = exp(! ), k = 0, 1, ..., N ! 1 (9-8) N

9-1 ESS 522 2014 in equation 9-7, the Z transform gives the components of the discrete of the time series bk. Fourier transforms are just a special case of the Z transform in which z is constrained to sit on the unit circle in the at uniformly spaced points.

As one might expect the properties of the Z transform are analogous to the Fourier transform and there are two that are particularly important for our applications.

First multiplication of a Z transform by z (equivalent to multiplying a DFT by exp(-2!ik/N)) results in a time delay of one sample.

Second convolution in the time domain is equivalent to multiplication in the Z transform domain (9-9) Z "!cj * d j $# = C(z).D(z) We can demonstrate this with a simple example. If the time domain

cj = [1 2 3], d j = [2 5] 1 2 3 (9-10) c * d = = 2 9 16 15 j j 5 2 [ ] In the Z transform domain C(z) = 1+ 2z + 3z, C(z) = 2 + 5z C(z).D(z) = (1! 2) + (2 ! 2 + 1! 5)z + (3 ! 2 + 2 ! 5)z2 + (3 ! 5)z3 (9-11) = 2 + 9z + 16z2 + 15z3 which gives the same result.

Frequency Response

As we showed in lecture 3, an alternative to characterizing a filter by measuring its impulse response in the time domain, we could also characterize its response by inputting a harmonic waves at different frequencies and characterizing its or . In the digital domain we can write " i2!kj % exp ( [L] ( yj (9-12) #$ N &' We know we can relate k and j to the frequency and time respectively by k f = , t = j!t (9-13) N!t By defining k f ' = , t ' = j (9-14) N we obtain a ‘dimensionless’ frequency that has a periodicity of 1 and a of 0.5, and a dimensionless time which has a sample interval of unity. Equation (9-12) becomes

exp(i2! f 't ') " L " yt ' (9-15) For convenience we will drop the primes.

We will consider 3 filters in both the frequency and the z domain

9-2 ESS 522 2014

1. Consider a very simple scaling filter (convolution with a single element filter b0). Equation (9-12) gives

exp(i2! ft) " [b0 ] " b0 exp(i2! ft) (9-16) The filter response is the output over the input and is given by output G( f ) X ( f ) Filter Transfer Function = = = G( f ) (9-17) input X ( f ) Clearly for the scaling filter we can write

G( f ) = b0 (9-18) The scaling filter has a flat frequency response.

We can generalize this filter to an arbitrary input

xt ! [b0 ] ! yt In the Z-domain

Y (z) = b0 X (z) to yield a transfer function (or response) Y (z) B(z) = = b0 X (z)

2. Now consider a unit delay filter (convolution with a filter [0 b1])

exp(i2! ft) " [b1z] " b1 exp %$i2! f (t # 1)'& (9-19) From equation (9-17) we get

G( f ) = b1 exp(!i2" f ) (9-20) The amplitude (or magnitude) spectrum is |G(f )| = b1 and the phase spectrum -2!f. The function acts to retard the phase by 2!f. The convention for filters is to use the phase lag spectrum (the negative of the phase spectrum) which is for this filter is " ( f ) = 2!f. As we are already aware from our work with the Fourier transform, one applies a delay or lag in the time domain by applying a linear adjustment to phase in the .

Again, we can generalize this filter to an arbitrary input

xt ! [b1z] ! yt (9-21) In the Z-domain this gives

Y (z) = b1zX (z) (9-22) which yields a transfer function (or response) Y (z) B(z) = = b1z (9-23) X (z)

3. Finally consider a two-element filter with [b0 b1]. Applying this filter to a harmonic filter gives

exp(i2! ft) " [b0 + b1z] " b0 exp[i2! ft] + b1 exp %$i2! f (t # 1)'& (9-24) The frequency response is 9-3 ESS 522 2014

G( f ) = b0 + b1 exp(!i2" f ) (9-25) = $#b0 + b1 cos(2" f )&% ! i $#b1 sin(2" f )&% We can generalize this filter to an arbitrary input

xt ! [b0 + b1z] ! yt (9-26) In the Z-domain

Y (z) = [b0 + b1z]X (z) (9-27) to yield a transfer function (or response) Y (z) B(z) = = b0 + b1z (9-28) X (z)

The amplitude spectrum is given by the magnitude of G( f ) 2 2 G( f ) = "b0 + b1 cos(2! f )$ + "b1 sin(2! f )$ # % # % (9-29) 2 2 = b0 + b1 + 2b0b1 cos(2! f ) The amplitude spectrum has two interesting properties.

First we can see that the two element filters [b0 b1] and [b1 b0] have the same amplitude – a set of filters with the same amplitude response is termed a suite.

Second we can see that if b0b1 > 0, that is if b0 and b1 have the same sign then |G(0)| > |G(0.5)| which means the amplitude response at zero frequency is higher than at the Nyquist frequency. We have a low pass filter. Conversely, if b0b1 < 0, that is if b0 and b1 have opposite signs, then |G(0)| < |G(0.5)| which means the amplitude response at zero frequency is lower than at the Nyquist frequency. We have a high pass filter.

The phase lag spectrum is given by

"1 $ b1 sin(2# f ) ' !( f ) = tan & ) (9-30) %b0 + b1 cos(2# f )( Now if |b0| > |b1|, it is clear that the denominator of equation (9-30) does not change sign. For -0.5 > f > 0.5, -!/2 < "(f ) < !/2 and if we look at the phase over a large interval it will remain bounded between these limits. However, if |b0| < |b1|, the denominator of equation will change sign and the expression in square brackets will go to infinity. For -0.5 > f > 0.5, "(f ) will vary between –! and ! and when viewed over a larger frequency interval it will be unbounded (once the 2! jumps are removed at the Nyquist frequency and its periodic repetition) For this reason a two element filter with |b0| > |b1| is known as while a two element filter with |b0| < |b1| is known as maximum phase.

An alternate way to write the filter response given by equation (9-28) is in terms of its root #

B(z) = b0 + b1z = kb (! " z)

b0 (9-31) kb = "b1; ! = " b1

9-4 ESS 522 2014

We can immediately see that for a value of z = #, the filter gives a response of zero. If the magnitude | # |>1 the filter is minimum phase while if | # |<1 it is maximum phase.

Filters with more than two elements can be constructed by convolving together two element filters. If all the component two-element filters are minimum phase then the resulting filter will be minimum phase and the phase will be bounded. If all the component two-element filters are maximum phase then the resulting filter will be maximum phase and the phase will be unbounded. If some of the two element component filters are minimum phase and others are maximum phase, the resulting filter is termed mixed-phase.

Unlike a two-element filter, the magnitude of the successive elements in a minimum phase filter does not decay monotonically but it does have the fastest build up of partial energy of the filter suite. That is the quantity M 2 (9-32) Epartial = "bj , 0 ! M < N j =o is a maximum for the minimum phase filter. For this reason minimum phase filters are also known as minimum delay filters. Maximum phase filters have the slowest build up of partial energy in a filter suite and are therefore are known as maximum delay.

For most applications, it is preferable to use either a minimum phase filter or a mixed-phase filter with a response (i.e., a constant delay for all frequencies).

9-5 Figure 9.1 Minimum Phase, b = [1 0.5] 1.5

1.4

1.3

1.2

1.1

1

Amplitude 0.9

0.8

0.7

0.6

0.5 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

0.6

0.4

0.2

0

ï0.2

Phase Lag, radians ï0.4

ï0.6

ï0.8 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Frequency Figure 9.2 Minimum Phase, b = [1 ï0.5] 1.5

1.4

1.3

1.2

1.1

1

Amplitude 0.9

0.8

0.7

0.6

0.5 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

0.6

0.4

0.2

0

ï0.2

Phase Lag, radians ï0.4

ï0.6

ï0.8 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Frequency Figure 9.3 Maximum Phase, b = [0.5 1] 1.5

1.4

1.3

1.2

1.1

1

Amplitude 0.9

0.8

0.7

0.6

0.5 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

0

ï1

ï2

ï3

ï4

Phase Lag, radians ï5

ï6

ï7 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Frequency