You are on page 1of 52

1

Lecture 11: LTI FIR filter design


Instructor:
Dr. Gleb V.
Tcheslavski
Contact:
gleb@ee.lamar.edu
Office Hours: Room
2030
Class web site:
http://ee.lamar.edu/gl
eb/dsp/index.htm

ELEN 5346/4304 DSP and Filter Design

Fall 2008

Preliminary considerations
M 1

H ( z ) hk z k

FIR filter:

(11.2.1)

k 0

transfer function

unit-pulse response
M 1

M 1

H ( z ) hk z k

BTW, using our


rational notation:

k
b
z
k
k 0

k 0

a0

;a0 1

(11.2.2)

Here M-1 is the filter order.


M is the number of filters coefficients. Assuming that M is odd:

H ( z ) h0 h1 z 1 h2 z 2 ... hM 2 z ( M 2) hM 1 z ( M 1)
z

M 1

h
M 1

ELEN 5346/4304 DSP and Filter Design

M 3
2

h z
k 0

M 1
k
2

Fall 2008

M 1

M 1
2

hk z

M 1
k
2

(11.2.3)

Preliminary considerations
For an FIR filter to have a linear phase:

hk hM* 1 k

(11.3.1)

That means an even symmetry of the coefficients.

H ( z) z

M 1

h
M 1

M 1

h
M 1
2

M 3
2

h z
k 0

M 3
2

k 0

M 1
k
2

hk z

M 3
2

h
k 0

M 1
k
2

M 1 k

hM 1 k z

M 1
k
2

M 1
k
2

(11.3.2)

Remember: FIR filters are always stable (no poles other than at the origin)!
ELEN 5346/4304 DSP and Filter Design

Fall 2008

Preliminary considerations
Since the filter is stable:

H (e j ) e

M 1
j
2

h
M 1

Here

M 1
j
2

M 3
2

k 0

hk e jhk e

M 1
k
2

e jhk e

M 1
k
2

M 3
2

M 1

h 2
h
cos

k
k
2

M21

k 0

1 4 4 4 4 4 4 44 2 4 4 4 4 4 4 4 43
Rc (e j )

(11.4.1)

Rc (e j ) is a real function of frequency.

As a result of symmetry:

He
ELEN 5346/4304 DSP and Filter Design

M 1
2

Fall 2008

Rc e j

(11.4.2)

Preliminary considerations
Therefore:

M 1
if Rc e j 0
2
M 1

if Rc e j 0
2

H e j

(11.5.1)

Generalized linear phase

to design ANY amplitude of frequency response: LPF,

We can use Rc e
HPF, BPF,

changes sign, the phase undergoes an abrupt change of 180

When Rc e

In M is even:

M 2
2

M 1

Rc (e j ) 2 hk cos
k hk

k 0
2

ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.5.2)

Preliminary considerations
An FIR filter will also have a linear phase in the case of odd symmetry of
filter coefficients (antisymmetric impulse response), i.e.:

hk hM* 1 k
It can be shown that

(11.6.1)

M 3
2

M 1

Rs (e j ) 2 hk sin
k hk ;M isodd

k 0
2

(11.6.2)

M 2
2

M 1

Rs (e j ) 2 hk sin
k hk ;M iseven

k 0
2

Therefore:

BTW:

H e j e

M 1
j
2

jRs e j

H jdifferentiator

H j sign Hilbert transformer

ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.6.3)

(11.6.4)
(11.6.5)
(11.6.6)

Preliminary considerations
Thus:
H e j

M 1
j
2 2 if Rs e 0

3 M 1 if R e j 0
s
2
2

(11.7.1)

Generalized linear phase

Summarizing, a unit-pulse response of a GLP FIR filter must satisfy:

hk hM* 1 k

(11.7.2)

M 1

H ( z ) hk z k

(11.7.3)

k 0

H e j e

M 1
j
2

Rc e j LPF , HPF , BPF , BSF ,...

j
jRs e differentiators ,Hilberttransformers

We only need to specify (M-1)/2 (odd M) or M/2 unique coefficients (even M).
ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.7.4)

Preliminary considerations
Combining (11.7.2) and (11.7.3), we arrive at:
M 1

H ( z ) hk z

k 0

( M 1)

M 1

h
k 0

*
M 1 k

M 1

m M 1 k hm* z m ( M 1)
m0

M 1

* m
( M 1)
*
*
h
z

z
H
1
z

(11.8.1)

m0

hasazeroatz z0 re

hasa zeroat z

1 1 j
e
*
z0 r

H ( z ) h0 h1 z 1 h2 z 2 h3 z 3 h4 z 4
Has two pairs of reciprocal zeros.
firls(4,[0 0.25],[1 0]);
ELEN 5346/4304 DSP and Filter Design

Fall 2008

Imaginary Part

Example: if M = 5:

0.5
4

0
-0.5
-1
-1

-0.5

0
Real Part

0.5

Preliminary considerations
There are four types of real GLP FIR filters:

Type I:
symmetric hn,
odd M
(number of
coefficients)
even order.

Type II:
symmetric hn,
even M

Type III:
antisymmetric
hn, odd M

Type IV:
antisymmetric
hn, even M

indicate structural zeros


ELEN 5346/4304 DSP and Filter Design

Fall 2008

10

Preliminary considerations
This is where structural zeros come from

1. For M = 4, symmetrical pulse response ( Type II FIR):

H ( z ) h0 h1 z 1 h2 z 2 h3 z 3 evensymmetry h0 h1 z 1 h1 z 2 h0 z 3
H ( z ) z 1 h0 h1 h1 h0 0

(11.10.1)

2. For M = 4, antisymmetrical pulse response ( Type IV FIR):

H ( z ) h0 h1 z 1 h2 z 2 h3 z 3 odd symmetry h0 h1 z 1 h1 z 2 h0 z 3
H ( z ) z 1 h0 h1 h1 h0 0

(11.10.2)

3. For M = 5, antisymmetrical pulse response ( Type III FIR):

H ( z ) h0 h1 z 1 h2 z 2 h3 z 3 h4 z 4 odd symmetry h0 h1 z 1 h2 z 2 h1 z 3 h0 z 4
H ( z ) z 1 h0 h1 h2 h1 h0 h2 0 0

H ( z ) z 1 h0 h1 h2 h1 h0 h2 0 0
ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.10.3)

11

Preliminary considerations
As a result of structural zeros
Type II FIR HPF would have a zero at - specs will be violated!
Type III FIR HPF would have a zero at - specs will be violated!
Type IV FIR LPF would have a zero at 0 - specs will be violated!
If something like tis happens, increase or decrease the FIR order to change
the type of your filter.
We need to be careful with selection of filter orders!

ELEN 5346/4304 DSP and Filter Design

Fall 2008

12

1. Least-square error minimization


The desired magnitude response (something we specify):

H d e j

j n
h
e
d ,n

(11.12.1)

H d e j e j n d

(11.12.2)

DTFT

Filter coefficients could be found as:

hd ,n

Example: Ideal LPF

hLPF ,n

jc n
jc n
2 j sin c n c sin c n
e

e
j n

1e d 2
2 j n

c n
c

(11.12.3)

Not causal, infinite length!


We need to preserve the main features while making the filter causal.
ELEN 5346/4304 DSP and Filter Design

Fall 2008

13

1. Least-square error minimization


The filter specified by (11.12.3) has an infinite impulse response. Therefore, we
need to truncate it at some point to make an FIR filter. As a criterion for such
truncation, we need to minimize the approximation error (the difference between
the desired and the truncated frequency responses).
Therefore, the objective is to find a finite-duration impulse response sequence,
whose DTFT would approximate the desired frequency response.
The magnitude of the frequency response of the truncated filter:
U

H t e j ht ,n e j n
n L

Where L and U are points at which the pulse response was truncated.
We need to minimize the least-square integral error of approximation.

ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.13.1)

14

1. Least-square error minimization


In particular:

1
min R
2
R

Ht e

H e
j

ht ,n hd ,n ht ,n hd ,n
2

nL

L 1

hd ,n

(11.14.1)

n U 1

hd ,n

(11.14.2)

Apparently, to minimize R (LS error), we select ht,n = hd,n for n = LU.


Moreover, GLP requires symmetry of filter coefficients, therefore L = -U.
The best finite length approximation of the ideal infinite length impulse response
in the LS error sense is obtained by truncation.
To make the resulting FIR causal, we need to shift it by L radians.

ELEN 5346/4304 DSP and Filter Design

Fall 2008

15

1. Least-square error minimization


Relating the point of truncation to the FIR filter order: L = (M 1)/2

hLPFIR ,n

M 1

sin c n
2
c

M 1

c n
2

(11.15.1)

0.2

0.2

0.1

0.1

0
-0.1
-50

Magnitude (dB)

0.3

0
0
n

Non-causal
ELEN 5346/4304 DSP and Filter Design

50

-0.1

20

40

60

Causal
Fall 2008

80

100

Phase (degrees)

0.3

hn

hn

Note: filter length M (number of filter coefficients) can be both even or odd.
0
-50
-100

0
0.2
0.4
0.6
0.8
1
Normalized Frequency ( rad/sample)

0
-2000
-4000

0
0.2
0.4
0.6
0.8
1
Normalized Frequency ( rad/sample)

16

2. Windowing effects
We can view the truncation of the infinite impulse response of an ideal filter as
windowing. In frequency domain, this operation is equivalent to convolution of
a frequency response of the window function with the frequency response of
an ideal filter.

ht ,n hd ,n wn

(11.16.1)

from the Modulation theorem:

Ht e

H d e j ( ) W e j d 1.2
W :
R

Gibbs phenomenon
(comes from truncated
Fourier series)
Ripples of equal magnitude in PB and SB
Transition band another window artifact
ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.16.2)
|Ht()|

|W()|
|Hd()|

0.8
0.6
0.4
0.2
0
-0.2
-1

-0.5

0.5

17

2. Windowing effects: window types


As discussed previously, different window functions can be used

Fixed windows:
Window
Rectangular

MLW (4/M) PSL (dB)

TB (2/M)

Max SB
ripple (dB)

0.9

-13

0.9

-21

Hanning

-31

3.1

-44

Hamming

-41

3.3

-53

Blackman

-57

5.5

-74

Window properties
ELEN 5346/4304 DSP and Filter Design

Fall 2008

Filter properties

18

2. Windowing effects: window types


Rectangular:

Hanning:

Hamming:

Blackman:

WnR 1,n 0,1,...M 1

(11.18.1)

1
2 n
2 2 n
W 1 cos
sin
,n 0,1,...M 1

2
M 1
M 1
(11.18.2)
N
n

2 n
,n 0,1,...M 1

M 1

WnM 0.54 0.46 cos

(11.18.3)

2 n
4 n
W 0.42 0.5cos
0.08cos
,n 0,1,...M 1

(11.18.4)
M 1
M 1
B
n

ELEN 5346/4304 DSP and Filter Design

Fall 2008

19

2. Windowing effects: window types


Adjustable windows:
Kaiser window:

2
2
n

I0 1
1

M 1

,n 0,1,...M 1
K
Wn
I0

Where:

x 2 m
I 0 ( x) 1

m 1
m !

Normally, 15-20 terms in the summation are sufficient.


Note: if = 0, WnK = WnR.

ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.19.1)

(11.19.2)

20

2. Windowing effects: window types


Properties:

TB (2/M)

Max SB ripple (dB)

1.5

-29

2.0

-37

2.6

-45

3.2

-54

4.5

-72

5.1

-81

Hanning
Hamming
Blackman

Kaiser window is the most frequently used for the FIR filter design.

ELEN 5346/4304 DSP and Filter Design

Fall 2008

21

2. Windowing: experimental design


For the given transition band:

Vf

s p

Stop-band attenuation:

A 20 lg s

Order estimate:

A 7.95
1
14.36 V f

(11.21.1)

(11.21.2)

(11.21.3)

0.1102 ( A 8.7) A 50dB

Adjustable parameter:

0.5842 ( A 21)0.4 0.07886 ( A 21)


21 A 50
0 A 21

(11.21.4)

M controls transition band, changes ripples.


Note: in practice, ripples in SB and PB are approximately equal. If this does not
hold, need to select minimum of s, p.
ELEN 5346/4304 DSP and Filter Design

Fall 2008

22

2. Windowing: experimental design


Example 11.1: design an FIR LPF using a Kaiser window for the following specs:

p 0.3 ;s 0.5 ; A 40dBminSBattenuation


s p 0.5 0.3

0.1
The transition band: V f
2
2
A 7.95
40 7.95
1
1 23.32
14.36 V f
14.36 0.1

Order:

Parameter:

0.5842 ( A 21) 0.4 0.07886 ( A 21) 3.4

We select M = 24, = 4. The filter is given by (11.15.1) with the cutoff frequency:

p s
c
0.4
2

The transfer function:

sin c n
ht ,n
wn ; L n L
n

The resulting filter is a type II FIR which is ok for LPF.


ELEN 5346/4304 DSP and Filter Design

Fall 2008

23

3. Frequency sampling
The desired frequency response
M 1

H d e j

DTFT

h
n0

j n
e
d ,n

(11.23.1)

can be specified by its frequency samples at equally spaced (discrete) frequencies:

k
Where

2
k
M
M 1
,M odd
2
M 2
0,1,...
,M even
2

0,1,...

/M

/M
2
ELEN 5346/4304 DSP and Filter Design

/M
2

= 0.5:

= 0:

0nooffset

0.5offsetby M
Fall 2008

(11.23.2)

(11.23.3)

(11.23.4)

24

3. Frequency sampling
The sampled frequency response will be:

H d , k H d e j

M 1

hd ,n e

2
( k ) n
M

,k 0,1,...M 1

(11.24.1)

n0

Evaluating IDFT:

1
hn
M

M 1

H
k 0

d , k

2
( k ) n
M

,n 0,1,...M 1

(11.24.2)

Therefore, we can compute the filter coefficients from the specified M


frequency samples.
Since hn is real:

H k H *M k

Since hn is symmetric, we only need to specify either (M+1)/2 (M is odd) or


M/2 (M is even) frequency samples to determine the pulse response.
ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.24.3)

25

3. Frequency sampling
We can rewrite the FIR filter frequency response (11.7.4) as:

He

H r e

j
H
e

e
r

M 1
2

,symmetrichn hM 1 n types

M 1
j

2
2

(11.25.1)

,antisymmetrichn hM 1 n types V

Sampled at the frequencies

k
k 2
;k 0,1,...M 1
M

(11.25.2)

the response becomes:

H k

ELEN 5346/4304 DSP and Filter Design

Hr
k

e
M

Fall 2008

2
M 1
j k

2
2 M

(11.25.3)

26

3. Frequency sampling
0symmetrichn

antisymmetrichn

Here:

(11.26.1)

For simplicity, we specify the following set of real frequency samples:

Gk

2
@ 1 H r
k ;k 0,1,...M 1
M

H k Gk e j k e

Therefore:

0

;
12

ELEN 5346/4304 DSP and Filter Design

2
M 1
j k

2
2 M

0
4differentcases...

Fall 2008

(11.26.2)

(11.26.3)

27

3. Frequency sampling
0symmetrichn
0nooffset :k 2 k M

Case 1:

H k Gk e j k e
M 1

1
hn
M

H e
k 0

2
kn
M

k 1

k 1

G0 Gk e
G0 Gk e

k
M

2 M 1
k

M 2

M 1

M
j

G e
k 0

2
kn
M

k
M

1

M

2
kn
M

GM k e

( M k )
M

2 M
k
M 2

G e
k 0

2
1
k n
M
2

Gk e

2
1
k n
M
2

k 1

k
M

Fall 2008

Gk e

2
kn
M

k
M
(11.27.1)

M 1

Ge

k U 1

k
M

2
kn
M

e e

j
j 2 n
1
e 1;e

j 2 n

1
k n ;n 0,1,...M 1
2

k
M

2
( M k ) n
M

k 1

2
G0 2Gk cos
k 1
M

ELEN 5346/4304 DSP and Filter Design

Gk e j k e

(11.27.2)

28

3. Frequency sampling
2
M

Gk 1 H r
k

Since hn is real:

2
H r
M

H k H M* k
2 M 1
2

jM k
k e

(11.28.1)
(11.28.2)

2
M 1
j M k
* 2

2
Hr
M k e M
M

(11.28.3)

Since Hr is real:

2
Hr
M

H r

2 M 1
jM k 2
2
k e
Hr
M
M

2
2
k H r
M k
M
M

2
H r
M

j
M k

M
k e

2 M
2

2
2

M 1
2

H r

2
M k e j M 1
M

2
k 1 H r
M k e j M k e j k e j 1 k
M

ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.28.4)

29

3. Frequency sampling
Therefore:

Gk GM k

(11.29.1)

The number of coefficients (frequency samples) to be specified:


M 1
2 ;odd M
U
M 1;evenM
2

(11.29.2)

- forced zero at z = -1

Since the unit-pulse response is already evaluated, we can estimate the


corresponding frequency response as its zero-padded DFT:

H e j DFT hn 0
and check whether the specifications are satisfied.

ELEN 5346/4304 DSP and Filter Design

Fall 2008

30

3. Frequency sampling
0symmetrichn
1 2ffset :k 2 (k 0.5) M

Case 2:

The desired frequency samples:

2
1
k
Gk 0.5 1 H r
k

2
M

(11.30.1)

2
hn
M

(11.30.2)

2
1
1
k

;n 0,1,...M 1
2
2
M

Gk 0.5 2sin
k 0

M 1
2 ;odd M
U
M 1;evenM
2

ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.30.3)

31

3. Frequency sampling
1antisymmetrichn
0noffset :k 2 k M

Case 3:

The desired frequency samples:

2 k

Gk 0.5 1 H r
k

2
hn
M

M 1

k 1

(11.31.1)

2 k
1
Gk sin
n ;M isodd
2
M

M 2 2
1
2
1
n 1
hn 1 GM 2 2 Gk sin
k n ;M iseven
M
2
k 1
M

ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.31.2)

(11.31.3)

32

3. Frequency sampling
1antisymmetrichn

Case 4:

0.5ffset :k 2 k 0.5 M

The desired frequency samples:

2 k 0.5

Gk 0.5 1 H r
k

2
hn
M

2
1
1
k

;n 0,1,...M 1
2
2
M

Gk 0.5 cos
k 0

M 3
;odd M

2
U
M 1;evenM
2

ELEN 5346/4304 DSP and Filter Design

(11.32.1)

(11.32.2)

(11.32.3)

Fall 2008

33

3. Frequency sampling
1.2

We specify the desired response in the


SB and the PB only

0.4

actual
specified

1
0.8
|H()|

0.6

0.2

1.2

0.1

0.2
0.3
fractional frequency

0.4

0.5

Alternatively, we can add transition sample(s)


and make the frequency response smoother.

0.6
0.4
0.2
0

0.8
|H()|

The stopband attenuation in this case


(only SB and PB samples are given) is
approximately -20 dB.

actual
specified

0.1

0.2
0.3
fractional frequency

ELEN 5346/4304 DSP and Filter Design

0.4

0.5

The stopband attenuation would be:


for one TB sample: approximately -40 dB.
for two TB sample: approximately -60 dB.
for three TB sample: approximately -80 dB.
Fall 2008

34

3. Frequency sampling
The transition band sample(s) optimized experimentally are:
# of TB samples

Sample(s) value(s)

SB attenuation, dB

0.3789795 if = 0
0.3570496 if = 0.5
[0.1065 0.5886]

~ 40

T3

[0.025779 0.251635 0.723071]


[0.030957 0.27557 0.744348]
Note: only one of them is correct.

~ 80

T4

[0.006061 0.09324 0.4082 0.82097]

~ 100

T1
T2

~ 60

Effects of adding TB sample(s) are increased SB attenuation and wider TB.


These samples must be optimized for the situation.
Selection of the offset can help too.
Note: we can specify any desired frequency response at the samples but not in
between! Ultimately, we can view all frequency samples as the TB samples,
which leads to an optimal (equiripple) design.
ELEN 5346/4304 DSP and Filter Design

Fall 2008

35

4. Optimal equiripple design


We are interested in a LP filter satisfying the following requirements:

1 p H r e j 1 p ;PB
s H r e

(11.35.1)

;SB
s

Considering four FIR types:


Type 1: symmetric pulse response, odd M.

hn hM 1 n

(11.35.2)

The real-valued frequency response:


M 3
2

M 1
M 1
n k
n
2
2

H r e j hM 1 2 hn cos
2

n0

hM 1 ,k 0

a
k 0

cos k

(11.35.3)

ak

M 1
2hM 1 ,k 1, 2,...
k
2

ELEN 5346/4304 DSP and Filter Design

M 1
2

Fall 2008

(11.35.4)

36

4. Optimal equiripple design


hn hM 1 n

Type 2: symmetric pulse response, even M.

(11.36.1)

The real-valued frequency response:


M 2
2

M
2

M 2
M 1

1
n k
n bk cos k
2
2

2
k 1

H r e j 2 hn cos
n 0

M 1
2

(11.36.3)

b%cos k

(11.36.4)

bk 2hM ,k 1, 2,...
2

H r e j cos

Or:

(11.36.2)

M
1
2
k 0

b%
0 0.5 b1
Where:

% ; k 1, 2,... M 2
b%

b
k
k
k 1
2
b%
2bM
M
2

ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.36.5)

37

4. Optimal equiripple design


Type 3: antisymmetric pulse response, odd M.

hn hM 1n

(11.37.1)

The real-valued frequency response:


M 3
2

M 1
M 1
n k
n
2
2

H r e j 2 hn sin
n 0

ck 2hM 1 ,k 1, 2,...
2

M 1
2

M 1
2

c
k 1

sin k

(11.37.2)

(11.37.3)

M 3
2

H r e j sin c%
k cos k

Or:

(11.37.4)

k 0

c%
M 3 c M 1
Where:

%
c%
k 1 ck 1 2ck ;2 k M 5 2
%
c%
0 0.5c2 c1

ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.37.5)

38

4. Optimal equiripple design


Type 4: antisymmetric pulse response, even M. hn hM 1 n

(11.38.1)

The real-valued frequency response:


M 2
2

M
2

M
M 1
n k
n d k sin k
2
2

k 1

H r e j 2 hn sin
n 0

d k 2hM ,k 1, 2,...
2

H r e j sin

Or:

M
2

(11.38.2)

(11.38.3)

M 2
2

d%cos k
k 0

(11.38.4)

d%
M 3 2d M
Where:

%
d%
k 1 d k 2d k ;2 k M 3 2
d% 0.5d% d
0

ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.38.5)

39

4. Optimal equiripple design


Therefore, we can express the frequency response for all FIR types as:

H r e j Q e j P e j
Where:
Filter type
1:
2:

P e


k 0

cos k

(11.39.2)

Q(ej )

hn hM 1 n M odd

hn hM 1 n M even

cos
2

3: hn hM 1 n M odd

sin

4: hn hM 1 n M even

sin
2

ELEN 5346/4304 DSP and Filter Design

(11.39.1)

Fall 2008

P(ej )
M 1

ak cos k

k 0

M 2

k 0

M 3

k 0

M 2

k 0

b%
k cos k
c%
k cos k

d%
k cos k

40

4. Optimal equiripple design


The desired frequency response:

H dr e
We can compute

1inPB

0inSB

(11.40.1)

H r e j and compare it to H dr e j . Adjusting P() and

selecting filter type, we can obtain the desired frequency characteristic.


We introduce the weighting function on the approximation error:

We

1inSB

s p inPB

If s < p bigger error in the passband is allowed.


ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.40.2)

41

4. Optimal equiripple design


The weighted approximation error:

E e j W e j H dr e j H r e j W e j H dr e j Q e j P e j
W e

Q e

H dr e j

Q e

P e W e j H dr e j P e j

(11.41.1)

Where the modified weighting function and the modified desired frequency
response are:

W e j W e j Q e j

H dr e j
ELEN 5346/4304 DSP and Filter Design

H dr e j
Q e

Fall 2008

(11.41.2)

(11.41.3)

42

4. Optimal equiripple design


For the given error function E(e j), the Chebyshev (mini-max)
approximation problem is to determine the filter parameters k that
minimize the maximum absolute error over the frequency bands of
interest:

min max E e
over k S

min max W e H dr e k cos k


over k
S
k 0

(11.42.1)

Usually, the frequency bands of interest are specified as:

S PB U SB

(11.42.2)

a disjoint union of the passband and the stopband: 0 - p and s - (for a LPF).
That is we ignore the transition band. More precisely speaking, error over the
TB will not be optimized.
The solution of this problem can be found via the alternation theorem.
ELEN 5346/4304 DSP and Filter Design

Fall 2008

43

4. Optimal equiripple design


The alternation theorem

A necessary and sufficient conditions for P e j cos k to be

k
k 0
unique and best approximation to H e j in S is that the error function
dr

E(e j) exhibit at least L + 2 extremal frequencies in S. That is, there must


exist at least L + 2 frequencies {i}, such that:

1 2 ... L 2

E e ji E e ji1

E e ji max E e j ,i 1, 2,..., L 2
S

I.e., error alternates in sign between two successive extremal frequencies.


ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.43.1)

(11.43.2)

(11.43.3)

44

4. Optimal equiripple design: Example


Example 11.2: design a LPF. Since both the desired frequency response Hdr
and the weighting function W are piecewise constants:

dE e j
d

W e j H dr e j H r e j
d

dH r e j
d

(11.44.1)

Consequently, the frequencies {i} that correspond to the peaks of the error
function E(e j) also correspond to the peaks of Hr(e j), i.e., where the frequency
response meets the specified error tolerance. Since Hr(e j) is a polynomial of
degree L:

Hr e


k 0

cos k k nk cos
k 0

n0

%
k cos

(11.44.2)

k 0

Hr(e j) has at most L-1 local minima and maxima and, therefore, at most L+1
extremal frequencies (bandages) since we add = 0 and = . Furthermore, the
band-edge frequencies p and s are also extrema of the error function.
Therefore, E(e j) has at most L+3 extremal frequencies.
ELEN 5346/4304 DSP and Filter Design

Fall 2008

45

4. Optimal equiripple design: Example


However, from the alternation theorem, there are at least L+2 extremal
frequencies in E(e j). Thus the error function for the LPF design will have either
L+2 or L+3 (extra ripple filters) extremal frequencies.
At the specified extremal frequencies n:

W e jn H dr e jn P e jn

alternations

1 ;n 0,1,...L 1
n

(11.45.1)

Here represents the maximum value of the error function E(e j).

H dr e jn n 0,1,...L 1

(11.45.2)

e jn n 0,1,...L 1
k cos n k

dr
W e jn
k 0

(11.45.3)

P e jn
or alternatively:

W e jn
n

ELEN 5346/4304 DSP and Filter Design

Fall 2008

46

4. Optimal equiripple design: Example


We can consider the {k} and as the unknown (to be determined)
design parameters for the given extremal frequencies. Therefore:
H dr e j0
1 cos 0
cos 20 L
cos L0
1 W e j0 0

1
H dr e j1
1 cos 1
cos 21 L
cos L1
1 W e L1
M

M
L
M

L 1
jL1
jL1

1 cos L 1 cos 2L 1 L cos LL 1 1


We

H dr e

Note: initially, both the design parameters and the extremal frequencies are
unknown. The above system can be solved by the iterative algorithm (Remez
exchange algorithm):
1)Guess the set of L + 1 extremal frequencies;
2)Solve for {k} and ;
3)Determine the error function as in (11.39.1);
4)Determine the new set of L + 1 extremal frequencies and go to 2)
Keep running until E(e j) - convergence.
ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.46.1)

47

4. Optimal equiripple design


Alternatively, we can compute analytically [Rabiner 75]:

0 H dr e j0 1 H dr e j1 ... L 1 H dr e jL1
0
1
(1) L 1

...

W e jL1
W e j0 W e j1
L 1

(11.47.1)

L 1

where:

1
k
n 0 cos k cos n

(11.47.2)

nk

Therefore, the initial guess of the L + 2 extremal frequencies allows us to


compute the maximum value of the error . Thus:
L

P e j k x k , x cos
k 0

ELEN 5346/4304 DSP and Filter Design

Fall 2008

(11.47.3)

48

4. Optimal equiripple design


Since we know that the polynomial at the points xn = cos n has the values:

P e

jn

H e
dr

jn

(1) n

,n 0,1,...L 1
jn

W e

(11.48.1)

the Lagrange interpolation formula can be used, which leads to


L

P e j

k 0

x x
k

x cos
xk cos k
L
1
k
n 0 xk xn
nk

ELEN 5346/4304 DSP and Filter Design

x xk

k 0

Here:

jk
P
e
k

Fall 2008

(11.48.2)

(11.48.3)
(11.48.4)
(11.48.5)

49

4. Optimal equiripple design


Having the solution for P, we can compute the error function:

E e j W e j H dr e j P e j

(11.49.1)

on a dense set of frequency points. Usually, 16M frequency points are sufficient.
If the error exceeds the estimated tolerance , we select a new set of
frequencies corresponding to the L+2 largest peaks of error function and the
procedure starts from (11.45.1). New set of critical frequencies will lead to
increased . As a result, the algorithm produces the optimal solution with equal
ripples in the PB and the SB for the given M.
The order of the filter can be estimated as:

ELEN 5346/4304 DSP and Filter Design

20 lg s p 13

14.6 s p
Fall 2008

(11.49.2)

50

Summary
Historically, the window-based algorithm was the first proposed method
for FIR design. Its major disadvantage is the lack of precise control of
the critical frequencies, such as s and p. These values, in general,
depend on the type of the window and the filter length M.
The frequency sampling method is attractive since it specifies an
arbitrary frequency response at the uniformly spaced frequencies and
the transition band is a multiple of 2/M. However, no control for the
response in between the samples.
The Chebyshev approximation method provides a total control of the
filter specifications and may lead to an equiripple design. This way, the
approximation error is spread evenly across the PB and SB, which
leads to an optimal filter. This method is usually preferred.

ELEN 5346/4304 DSP and Filter Design

Fall 2008

51

Remarks and conclusions


Since orders of FIR filters can be quite high, these filters can introduce a
considerable group delay, which is approximately M/2.
The following Matlab functions are handy for FIR design:
fir1 FIR filter design using the windowing method
fir2 FIR filter design via the frequency sampling method
firpm Parks-McClellan optimal equiripple FIR design
firpmord - Parks-McClellan optimal equiripple FIR order estimator

ELEN 5346/4304 DSP and Filter Design

Fall 2008

52

Appendix: the ideal transfer functions


LPF:

hLP ,n

sin c n

, n
n

(11.52.1)

1 c ,n 0
HPF:

BPF:

sin c n
, n 0

n

hHP ,n

hBP ,n

sin c 2 n sin c1n

, n 0
n
n

BSF:

ELEN 5346/4304 DSP and Filter Design

(11.52.3)

c 2 c1

1
,n 0

sin c1n sin c 2 n , n 0

n
n

hBS ,n

(11.52.2)

Fall 2008

(11.52.4)

You might also like