Chapter 3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 94

CHAPTER 3:

CHAPTER 3:
FIR FILTER DESIGN
FIR FILTER DESIGN
1. Preliminaries
2. Window design techniques
3. Frequency sampling design techniques
4. Optimal equiripple design techniques
Duration: 8 hrs
Preliminaries
Preliminaries
1. Why FIR?
2. Filter design steps
3. Frequency domain specifications
4. Properties of linear-phase FIR filters
Why FIR?
Why FIR?
Easy to design: no poles no stability problem
Can use FFT approach (linear convolution)
Linear phase no phase distortion
Symmetry efficient to implement
Preliminaries
Preliminaries
1. Why FIR?
2. Filter design steps
3. Frequency domain specifications
4. Properties of linear-phase FIR filters
Filter design steps
Filter design steps
3 steps:
Speech signal
1. Frequency domain specifications (magnitude and/or
phase)
2. Filter design and approximation (different design
methodologies, different filter lengths, leading to
different FIR filters all satisfying the same specification!)
3. Hardware/software implementation (structure -- direct
form, linear phase form, frequency sampling form, or
lattice)
Preliminaries
Preliminaries
1. Why FIR?
2. Filter design steps
3. Frequency domain specifications
4. Properties of linear-phase FIR filters
Frequency domain specifications
Frequency domain specifications
.
Three bands: pass [0,
p
], transition [
p
,
s
] and stop [
s
, ]
Desirable frequency magnitudes |H(e
j
)|, and/or phases <H(e
j
)
Absolute and Relative Magnitude Spec.
Absolute and Relative Magnitude Spec.
Absolute:
Relative:
Examples:
ripple or tolerance with passband the , ] , 0 [
1

p
w
ripple or tolerance with stopband the , ] , [
2

s
w
0
1
1
log 20
1
1
10
>
+

p
R
0
1
log 20
1
2
10
>
+
=

s
A
0144 . 0
1
1
log 20 25 . 0
1
1
1
10
=
+

= =

dB R
p
0032 . 0
1
log 20 50
2
1
2
10
=
+
= =

dB A
s
Preliminaries
Preliminaries
1. Why FIR?
2. Filter design steps
3. Frequency domain specifications
4. Properties of linear-phase FIR filters
Properties of linear
Properties of linear
-
-
phase FIR filters
phase FIR filters
Impulse response Phase response
) 1 ( ) ( n M h n h =
) 1 ( ) ( n M h n h =
2
1
) (

=
=
M
e H
j

2 2
1
) (

=
=
M
e H
j
Symmetry
Anti-symmetry
Phase delay <H(e
j
)/ constant phase delay with
symmetrical filters
Group delay d<H(e
j
)/d constant group delay with
anti-symmetrical filters
An example of linear
An example of linear
-
-
phase FIR filter
phase FIR filter

j j
e e H n h

+ = = ) cos 2 1 ( ) ( ] 1 1 1 [ ) (
0 0. 5 1
- 4
- 2
0
2
0 0. 5 1
- 4
- 3
- 2
- 1
0
0 0. 5 1
0
1
2
3
0 0. 5 1
- 1
0
1
2
3
Frequency in pi units
Magnitude
response
Amplitude
response
Phase
response
Piecewise
phase
response
Zero locations
Zero locations
Transfer function:
Real impulse response:
Zero constellation:
quadruplet
) ( ) ( *
) ( ) ( *
1
1
z H z z H
z H z H
M

=
=
) ( ) (
) 1 ( 0 ) 1 ( ) (
1 ) 1 (
=
=
z H z z H
M n n M h n h
M
j j j j
e
r
re e
r
re

1 1
Some examples of zero locations
Some examples of zero locations
-1.5 -1 -0.5 0 0.5 1 1.5
-1
-0.5
0
0.5
1
10
Real Part
I
m
a
g
i
n
a
r
y

P
a
r
t
-1.5 -1 -0.5 0 0.5 1 1.5
-1
-0.5
0
0.5
1
11
Real Part
I
m
a
g
i
n
a
r
y

P
a
r
t
Type 4
h(n) = [ -4 1 -1 -2 5 6 -6 -5 2 1 -1 4 ]
Type 1
h(n) = [ -4 1 -1 -2 5 6 5 -2 -1 1 -4 ]
Type I:
Type I:
M
M
odd
odd
Symmetric
Symmetric
)
2
1
( 2 ) ( ),
2
1
( ) 0 (
) ( cos ) ( ) (
) 1 ( ) (
2
1
2
1
2 / ) 1 (
0
n
M
h n a
M
h a
e H e n n a e H
n M h n h
M
j
r
M
j
M
n
j

=
=
(

=
=


Type II:
Type II:
M
M
Even
Even
Symmetric
Symmetric
bandstop or highpass no , 0 ) (
) ( ) 2 / 1 ( cos ) ( ) (
)
2
( 2 ) ( ), 1 ( ) (
2
1
2
1
2 /
1
=
=
(

=
= =

r
M
j
r
M
j
M
n
j
H
e H e n n b e H
n
M
h n b n M h n h
Type III:
Type III:
M
M
Odd
Odd
Anti
Anti
-
-
Symmetric
Symmetric



2
1
)
2
1
2
( )
2
1
2
(
2 / ) 1 (
0
) ( ) ( , 0 ) ( ) 0 (
) ( sin ) ( ) (
)
2
1
( 2 ) ( ), 1 ( ) (

=
= = =
=
(

= =

M
j
r
j
r r
M
j
r
M
j
M
n
j
e jH e H H H
e H e n n c e H
n
M
h n c n M h n h
Suitable for digital differentiator or Hilbert transformer
Type IV:
Type IV:
M
M
Even
Even
Anti
Anti
-
-
Symmetric
Symmetric


2
1
)
2
1
2
( )
2
1
2
(
2 /
0
) ( ) ( , 0 ) 0 (
) ( ) 2 / 1 ( sin ) ( ) (
)
2
( 2 ) ( ), 1 ( ) (

=
= =
=
(

=
= =

M
j
r
j
r
M
j
r
M
j
M
n
j
e jH e H H
e H e n n d e H
n
M
h n d n M h n h
Suitable for digital differentiator or Hilbert transformer
Window design techniques
Window design techniques
1. Preliminaries
2. Commonly used windows
3. Optimal window Kaiser window
4. Design examples
Basic window design idea
Basic window design idea
Choose a proper ideal filter and then truncate its impulse
response to obtain a linear-phase and causal FIR filter
Truncate = window
Ideal filter: unity magnitude gain and linear-phase over its
passband and zero response over its stopband
Basic idea: given the filter specifications, choose the
filter length M and a window function w(n)
FIR Design by Windowing
FIR Design by Windowing
Given an ideal lowpass filter (LPF) specified in frequency:

<

=


c
c
j
j
d
e
e H
, 0
, 1
) (

c
c
) (
e H
j
d

c c
) (
e H
j
d

already version " by shifted " a is that note


) (
)] ( sin[
1
2
1
) (
2
1
)} ( { ) (


(n) h
n
n
d e e
d e e H e H IDTFT n h
d
c
n j j
n j j
d
j
d d
c
c


= =
= =

Impulse responses of other ideal filters


Impulse responses of other ideal filters
Highpass: one minus the lowpass
Bandpass: difference of two lowpass
Bandstop: one minus the bandpass

=
=
2
1
1 ,
) (
)] ( sin[
, 1
) (
M
n
n
n
n
n h
c
c
d

=
2
1
1 ,
) (
)] ( sin[
) (
)] ( sin[
, 1
) (
2 1
1 2
M
n
n
n
n
n
n
n h
c c
c c
d





1 0 ,
) (
)] ( sin[
) (
)] ( sin[
) (
1 2


= M n
n
n
n
n
n h
c c
d




Windowing
Windowing
h
d
(n) is of infinite length need to truncate it to length M.


= =
else
M n n h
n w n h n h
d
d
, 0
1 0 ), (
) ( ) ( ) (


= =

d e H e W e W e H e H
j
d
j j j
d
j
) ( ) (
2
1
) ( ) ( ) (
) (
Some observations of windowing
Some observations of windowing
When w(n) is also of infinite length:
The peak height of main lobe of W(e
j
) is proportional to M
The periodic convolution produced a smeared version of
H
d
(e
j
)
The main lobe width of W(e
j
) determines the transition width
of H(e
j
):
Wider main lobe wider transition width
The side lobe of W(e
j
) produces H(e
j
) ripples that have
similar shapes in passband and stopband
) ( 1 ) (

j
d
j j
e H ) H(e ) ( ) W(e n n w = = =
Window design techniques
Window design techniques
1. Preliminaries
2. Commonly used windows
3. Optimal window Kaiser window
4. Design examples
Commonly used windows
Commonly used windows
Rectangular window
Bartlett window
Hanning window
Hamming window
Blackman window
Rectangular Window
Rectangular Window

2
1
)
2
sin(
)
2
sin(
) (
, 0
1 0 , 1
) (


=
M
j
j
e
M
e W
else
M n
n w
Gibbs
Phenomenon
M
w
8 . 1
=
Bartlett (Triangular) Window
Bartlett (Triangular) Window

=
else
M
M
n
M
n
M
n
n w
, 0
1 - M n
2
1
,
1
2
2
2
1
0 ,
1
2
) (
M
w
1 . 6
=
Hanning
Hanning
Window
Window

=
otherwise
M n
M
n
n w
, 0
1 0 )],
1
2
cos( 1 [ 5 . 0
) (

M
w
2 . 6
=
Hamming Window
Hamming Window

=
otherwise
M n
M
n
n w
, 0
1 0 ),
1
2
cos( 46 . 0 54 . 0
) (

M
w
6 . 6
=
Blackman Window
Blackman Window

=
otherwise
M n
M
n
M
n
n w
, 0
1 0 ),
1
4
cos( 08 . 0 )
1
2
cos( 5 . 0 42 . 0
) (

M
w
11
=
Summary of Commonly Used Windows
Summary of Commonly Used Windows
Window design techniques
Window design techniques
1. Preliminaries
2. Commonly used windows
3. Optimal window Kaiser window
4. Design examples
Optimal Kaiser Window
Optimal Kaiser Window
Given a specific stopband attenuation, can we get the sharpest
transition width? -- Kaiser window!
I
0
(x): modified zero-th order Bessel function of 1
st
kind (normally,
15 terms)
: shape parameter, determines the tradeoff between the
mainlobe width and peak sidelobe level, typically


=
+ =

(


=
1
2
0
0
2
0
!
) 2 / (
1 ) (
1 0 ,
) (
)
1
2
1 ( 1
) (
m
m
x
m
x I
M n
I
M
n
I
n w

9 4 < <
dB 60 atten. stopband min
8 . 7
658 . 5 = = =
M
w

More About Kaiser Window


More About Kaiser Window
Design Procedure:

< < +

=
+

=
50 21 ), 7 . 8 ( 07886 . 0 ) 21 ( 5842 . 0
50 ), 7 . 8 ( 1102 . 0
1
36 . 14
95 . 7
order filter
2
, , ,
4 . 0
s s s
s s
s
p s
s p s p
A A A
A A
f
A
M
f
A R Given



M
w
8 . 7
=
Window design techniques
Window design techniques
1. Preliminaries
2. Commonly used windows
3. Optimal window Kaiser window
4. Design examples
Design Example: Lowpass FIR
Design Example: Lowpass FIR
Design the LPF with the following specifications:
1. Choose the Hamming window
2. Determine the filter length
3. Create ideal lowpass filter
dB A
dB R
s s
p p
50 , 3 . 0
25 . 0 , 2 . 0
= =
= =


67 1 )
6 . 6
( = +

ceil M
2
,
) (
)] ( sin[
) (
s p
c
c
d
n
n
n h



+
=

=
Design Example: Lowpass FIR (cont.)
Design Example: Lowpass FIR (cont.)
Design the LPF with the following specifications:
4. Create Hamming window function w(n)
5. Truncate the ideal impulse
response:
dB A
dB R
s s
p p
50 , 3 . 0
25 . 0 , 2 . 0
= =
= =

\
|

=
otherwise
n
n
n w
, 0
66 0 ,
33
cos 46 . 0 54 . 0
) (

) ( ) ( ) ( n w n h n h
d
=
Design Example: Bandpass FIR
Design Example: Bandpass FIR
BPF = LPF1 + LPF2
dB A dB R
dB R dB A
s s p p
p p s s
60 , 8 . 0 , 1 , 65 . 0
1 , 35 . 0 , 60 , 2 . 0
2 2
1 1
= = = =
= = = =


Design the BPF with the following specifications:
Bandpass Filter Design (cont.)
Bandpass Filter Design (cont.)
The filter length (use Blackman):
Create two ideal lowpass filters (c=c1 or c2)
h(n)=[h
c1
(n)-h
c2
(n)]w(n)
75 1
} , min{
11
1
} min{
11
2 2 1 1
= +
|
|

\
|

= +
|
|

\
|

=
p s s p
ceil ceil M

2
,
) (
)] ( sin[
or
2 1
s p
c
c
c c
n
n
(n) h (n) h



+
=


=
Hilbert Transformers
Hilbert Transformers
Types 3 & 4 linear phase FIR filter
All-pass filter
Imparts a constant phase shift
Useful for creating half-band signal
0 for 2 / and 0 for 2 / < > f f
) sgn( ) ( ., .
0 , 1
0 , 1
) sgn(
), sgn( ) (
f f jH e i
f
f
f where
f j f H
Hilb
Hilb
=

<
>

<
>
=
(

+
=
0 , 0
0 ), (
), (
2
) sgn( 1
) (
f
f f X
f X
f
f Y
a
a a
Hilbert
Hilbert
Transformers
Transformers


= = =

< < +
< <
=

n
n
n
n
e H IDTFT b n h
w je
w je
e H
jw
d n d
w j
w j
jw
d
, 0
,
2 / ) ( sin 2
)} ( { ) (
0 ,
0 ,
) (
2
M=31, rectangular window M=31, Hamming window
Matlab
Matlab
functions
functions
w = boxcar(M): returns the M-point rectangular window
function in array w
w = triang(M): returns the M-point Bartlett window function
in array w
w = hanning(M): returns the M-point Hanning window
function in array w
w = hamming(M): returns the M-point Hamming window
function in array w
w = blackman(M): returns the M-point Blackman window
function in array w
w = kaiser(M, beta): returns the beta-valued M-point kaiser
window function in array w
Frequency sampling design
Frequency sampling design
techniques
techniques
1. Preliminaries
2. Nave design method
3. Optimum design method
Why frequency sampling?
Why frequency sampling?
The windowing techniques require the knowledge of h
d
(n),
which is sometimes not easily available
Suitable to the frequency sampling structure in FIR
implementation
The system function H(z) can be easily obtained based on
these M uniformly sampled data H(k)
) (
1
0
1
)
2
( ) (
,
1
) ( 1
) (
k H j
r
M
k
k
M
M
e
M
k
H k H where
z W
k H
M
z
z H

|
|

\
|

=

How to perform frequency sampling?


How to perform frequency sampling?
Three important facts of defining H(k):
- conjugate symmetry of H(k) (since h(n) is real), simply for
passband |H(k)|=1, otherwise |H(k)|=0.
- linear phase
- always sample ) 2 , 0 [
How to perform frequency sampling
How to perform frequency sampling
(cont.)
(cont.)
Floor fx.
Equation (*)
Basic design idea
Basic design idea
Basic idea: given the ideal filter H
d
(e
j
), choose the filter length
M, then sample H
d
(e
j
) at M equispaced frequencies in [0, 2),
then infer H(e
j
) from the interpolation of the samples H(k)
Observations:
- the approximation error is zero at the sampled frequencies
- the error is larger at sharper region of the ideal response
Frequency sampling design
Frequency sampling design
techniques
techniques
1. Preliminaries
2. Nave design method
3. Optimum design method
Naive design method
Naive design method
No constraints on the approximation error; mean
we accept whatever error we get from the
design.
Set H(k) = H
d
(e
j2k/M
), k = 0, 1, , M-1
Use equation (*) to obtain the impulse response
h(n)
Naive Design Example
Naive Design Example
Design a lowpass FIR filter with the following specifications
Choose M=20 (Type 2):
- Sample H
d
(e
j
) at
- Passband covers
- The rest = transition and stopband =0
dB A
dB R
s s
p p
50 , 3 . 0
25 . 0 , 2 . 0
= =
= =


k
k
k

1 . 0
20
2
= =
1 19 2 18
2 1 0
9 . 1 , 8 . 1
, 2 . 0 , 1 . 0 , 0


= = = =
= = = =
p

=
=
=
= =

19 10 ), 1 . 0 2 ( 5 . 9 ) 2 (
9 0 , 1 . 0 5 . 9
) (
0000000011 1110000000 ) ( ) ( ) (
) (
k k
k k
k H
] [ k H e k H k H
k
k
r
k H j
r


Naive Design Example (cont.)
Naive Design Example (cont.)
Obtain the impulse response of the filter h(n)=IDFT{H(k)}
Take DTFT{h(n)} to obtain H(e
j
)
Note that the stopband attenuation = 16 dB (does not satisfy the
given spec.) --> increase the length (sample more H(k) points)
Naive Design Example
Naive Design Example
(M=40)
(M=40)
Sample H
d
(e
j
) at
Passband covers:
The transition band covers:
The rest are stopband, in total 29 zeros:
k
k
k

05 . 0
40
2
= =

=
=
=
=
=

39 20 ), 05 . 0 2 ( 5 . 19 ) 2 (
19 0 , 05 . 0 5 . 19
) (
] 1111 000 ... 000 11111 [ ) (
) ( ) (
1 1
) (
k k
k k
k H
T T k H
e k H k H
k
k
r
k H j
r


39 38 37 36 4 3 2 1 0
, , , , , , , , ,
p p
= =
1 35 5
) ( ) ( T H H = =
Naive Design Example (M=40)
Since the transition band samples are free samples, how
about make it
?) 38 . 0 be (should 39 . 0 or , 5 . 0
1 1
= = T T
Frequency sampling design
Frequency sampling design
techniques
techniques
1. Preliminaries
2. Nave design method
3. Optimum design method
Transition
Transition
-
-
Band Optimization
Band Optimization
To find a value for x which maximizes the stopband
attenuation by assuming it is a quadratic
polynomial (so that we can easily identify a global optimal
point
This is a typical linear regression to approximate any
unknown function
2
3 2 1
) ( x c x c c x H
s
+ + =
) ( | ) ( x H x H
s r
s
=
=
Transition
Transition
-
-
band optimization (cont.)
band optimization (cont.)
Find the polynomial coefficients {c
1
, c
2
, c
3
} by arbitrarily
selecting some {x} points (at least 3 points, can be more
than that, then we have to solve a least squares solution)
How to obtain three {H
s
(x
i
)} at
s
?
- Take all M frequency samples (including the unknown
value x
i
)
- Perform IDFT, to get h(n)
- Derive DTFT H(e
j
) we can evaluate {H
s
(x
i
)}
Transition
Transition
-
-
band optimization (cont.)
band optimization (cont.)
Once {c
i
} are determined, the regression polynomial for H
s
(x) is
set and this quadratic polynomial can be easily maximized
]! , , [ solve can we
] 75 . 0 , 5 . 0 , 25 . 0 [ ] , , [ choosing By
) (
) (
) (
1
1
1
3 2 1
3 2 1
3
2
1
3
2
1
2
3 3
2
2 2
2
1 1
c c c
x x x
x H
x H
x H
c
c
c
x x
x x
x x
s
s
s
=
(
(
(

=
(
(
(

(
(
(

3
2
1 max
2
3 2 1
2
) (
c
c
T x x c x c c x H
s

= = + + =
Tables of transition coefficients
Tables of transition coefficients
Four tables list the transition coefficients
- B1: for = 0 and one coefficient in the transition band
- B2: for = 0 and two coefficients in the transition band
- B3: for = , one coefficient in the transition band, M even
- B4: for = , two coefficients in the transition band, M even
Specifications:
- BW: number of frequency points at which H(
k
) = 1
- Transition width: (2/M) times the number of transition
coefficients
- Maximum tolerate sidelobe in the stopband
Optimum design example
Optimum design example
Choose M=60 (Type 2)
BW=7
T
1
=0.5925
T
2
=0.1099
chosen optimally
] 111111 000 ... 000 1111111 [ ) (
1 2 2 1
T T T T k H
r
=
43 zeros
63dB
Bandpass filter frequency sampling design
Bandpass filter frequency sampling design
Recall the bandpass design using two lowpass windowing:
dB A w
dB R w
dB R w
dB A w
s s
p p
p p
s s
60 , 8 . 0
, 1 , 65 . 0
1 , 35 . 0
, 60 , 2 . 0
2 2
2 2
1 1
1 1
= =
= =
= =
= =

] 0 ... 0 1111111 0 ... 0 1111111 0 ... 0 [ ) (


1 2 2 1 1 2 2 1
T T T T T T T T k H
r
=
0.59417456
0.109021,
2
1
=
=
T
T
60dB
Digital differentiator design
Digital differentiator design
Useful in enhancing rapid transition (e.g., transients in 1-D
and edges in 2-D signals)
Ideal differentiator:


=
= =

1 1 ]
2
1
[ , ) (
1
]
2
1
[ 0 ,
2
2
1
) (
1 1 ]
2
1
[ ), (
2
]
2
1
[ 0 ,
2
) (
)} ( { ) ( , ) ( ) (
) (
M k
M
floor k M
M
M
M
floor k k
M
M
k H
M k
M
floor k M
M
j
M
floor k k
M
j
k jH
k H IDFT n h e k jH k H
r
k H j
r

< <
<
=
0 ,
0 ,
) (

j
j
e H
j
d
Digital differentiator FIR design (cont.)
Digital differentiator FIR design (cont.)
Optimal equiripple design
Optimal equiripple design
techniques
techniques
1. Preliminaries
2. Minimax criterion
3. Alternation theorem
4. Remez exchange design example
Why optimal equiripple design?
Why optimal equiripple design?
The windowing + frequency sampling techniques:
- Cant specify
p
,
s
, R
p
, A
s
exactly
- Cant specify both
1
and
2
simultaneously, e.g., only
1
=

2
in windowing, while only
2
is optimized in frequency
sampling
- The approximation error: larger near the band edge, and
smaller away from the band edge
Optimal equiripple design: eliminate all above problems
How to perform optimal equiripple design?
How to perform optimal equiripple design?
Objectives:
- Equi-ripple filter, i.e the error can be uniformly distributed
- Minimize the maximum approximation error (minimax
problem), i.e the maximum ripple can be minimized
Optimal equi-ripple design using Remez exchange
algorithm:
- Rewrite the frequency response of FIR filter as the common
form for all four cases make the problem easier
- Formulate the design problem as a Chebyshev
approximation problem
Optimal equiripple design
Optimal equiripple design
techniques
techniques
1. Preliminaries
2. Minimax criterion
3. Alternation theorem
4. Remez exchange design example
Frequency Response for Linear Phase FIR
Frequency Response for Linear Phase FIR

\
|

=
2
1
) ( ) (
M
j
j j
r
j
e e e H e H
Amplitude Response for Linear Phase FIR
Amplitude Response for Linear Phase FIR
cos ) ( ) ( ) ( ) ( ) (
0

=
= =
L
n
j
r
n n Q P Q e H

Weight Error Formulation


Weight Error Formulation
The weighted error:
where
] cos ) ( ) ( )[ (
] cos ) (
) (
) (
)[ ( ) (
)] (
) (
) (
)[ ( ) (
)] ( ) ( ) ( )[ (
] , [ ] , 0 [ )], ( ) ( )[ ( ) (
0
^ ^
0


=
=
=
=
=
=
= =
L
n
rd
L
n
dr
dr
dr
s p r dr
n n H W
n n
Q
H
Q W
P
Q
H
Q W
P Q H W
S H H W E




) (
~
), (
~
), (
~
), ( ) ( n d n c n b n a n =
, W(): weighted function
: common form
for E()
Weight Error Formulation (cont.)
Weight Error Formulation (cont.)
W() is necessary so that we
can have an independent
control over
1
and
2

=
stopband the in , 1
passband the in ,
) (
1
2

W
MINMAX problem statement
MINMAX problem statement
Determine the set of (n) to minimize the
maximum absolute value of E() over the pass
band and stop band, i.e:
] cos ) ( ) ( )[ ( ) (
0
^ ^

=
=
L
n
rd
n n H W E
| | | ) ( | max min

E
S coeff over
Recall the weighted error:
MINMAX problem statement (cont.)
MINMAX problem statement (cont.)
Discuss: how many extremes exist in E()?
- Polynomials of order L in terms of cos has at most L-1
extremes
- Two points = 0 and = are also extreme points
- The band edges points,
p
,
s
are also extreme points
at most (L+3) extreme points.
P() can be converted in term of cos

= =
= =
L
n
n
L
n
n n n P
0 0
cos ) ( cos ) ( ) (
. .......... ..........
cos 3 cos 4 3 cos
1 cos 2 2 cos :
3
2


=
= Ex
Example of
Example of
Minimax
Minimax
Formulation
Formulation
].
15
8
,
15
8
, 0 , 0 [ ) ( . .
cos ) ( cos
15
8
cos
15
8
0 0
)} cos 3 cos 4 ( 2 ) 1 cos 2 ( 4 cos 6 4 {
15
1
) 3 cos 2 2 cos 4 cos 6 4 (
15
1
cos ) ( ) (
] 2 , 4 , 6 , 4 [
15
1
) (
) 3 ( ) 0 ( ) 0 ( and , 3 1 ), 3 ( 2 ) ( ) (
3 2 / ) 1 ( , 7 ], 1 , 2 , 3 , 4 , 3 , 2 , 1 [
15
1
) (
3
0
3 2
3 2
3
0
=
= + + + =
+ + + =
+ + + = =
=
= = = =
= = = =

=
=
n e i
n
n n P
n
h a n n h n a n
M L M n h
n
n
n


Example of
Example of
minimax
minimax
formulation (cont.)
formulation (cont.)
P() has (L-1) = 2
extremes in the open
interval
The error function has
at most (L+3) = 6
extremes.
< < 0
Example of
Example of
L=7
L=7
Optimal equiripple design
Optimal equiripple design
techniques
techniques
1. Preliminaries
2. Minimax criterion
3. Alternation theorem
4. Remez exchange design example
Alternation theorem
Alternation theorem
Let S be any closed subset of the closed interval (0,). In
order that P() be the unique minimax approximation to
H
dr
() on S, it is necessary and sufficient that the error
function E() exhibit at least (L+2) extremal frequencies in
S; that is, there must exist (L+2) frequencies
i
in S such
that
S
E E E
L
S
i i
< < < =
= =
+

1 1 0
1
... ,
| ) ( | max ) ( ) (


How to calculate these extremes
i
?
Remez
Remez
exchange algorithm
exchange algorithm
Solve an (L+2)x(L+2) linear system to get (L+1) (n) and ?
(
(
(
(
(
(
(

=
(
(
(
(
(
(

(
(
(
(
(
(
(

=
=
+
+
+ + +
=
=

) (
) (
) (
) (
) (
) (
) (
) 1 (
) 0 (
) ( ) (
1
cos 2 cos cos 1
) ( ) (
1
cos 2 cos cos 1
) ( ) (
1
cos 2 cos cos 1
cos ) (
) ( ) (
) 1 (
) (
) (
) 1 ( ] cos ) (
) (
) (
)[ ( ) (
1
1
1
1
0
0
1 1 1
1 1 1
0 0 0
0
0
L
L dr
dr
dr
i i
L L L
i i
i i
L
n
i
i i
i
i
i dr
i
L
n
i
i
i dr
i i
Q
H
Q
H
Q
H
L
Q W
L
Q W
L
Q W
L
n n
Q W Q
H
n n
Q
H
Q W


M
M
L
M M O M M M
L
L
Remez
Remez
exchange algorithm (cont.)
exchange algorithm (cont.)
Note that this linear equation satisfies both passband and
stopband ripple specifications. Assume Q(w)=1:
Idea: looking for (non-uniform) extreme frequency locations {
i
}
iteratively, so that the equiripple error formulation can be satisfied.
Since there are (L+2) unknown (including ), and we are solving
an (L+2)x(L+2) linear equation system, the solution is unique IF
the (L+2) extreme frequencies {
i
} are known in advance. This is
why we need to iterate until convergence!

=
=

=
stopband
passband
w W
w P w H
i
i i
i
i
i i d
, ) 1 (
, ) 1 ( ) 1 (
) (
) 1 (
) ( ) (
2
1 2
2
1

Remez
Remez
exchange algorithm (cont.)
exchange algorithm (cont.)
Step 1: a set of initial values for extremal frequencies {
i
}
are either chosen or are available from the completion of
the previous iteration.
Step 2: Solve the (L+2)x(L+2) linear system to obtain
(L+1) (n) and

=
+

=
L
n
i
i i
i
i
i dr
n n
Q W Q
H
0
cos ) (
) ( ) (
) 1 (
) (
) (


Remez
Remez
exchange algorithm (cont.)
exchange algorithm (cont.)
Step 3: The values of the weighted error function over the
closed subset S of the frequency range are
determined by interpolating the values at the (L+2) extremal
frequencies using the Lagrange interpolation formula.
Step 4: Determine the (L+2) new extremal frequencies from
the weighted error function. Go back to Step 1, until
converge.
If is not satisfactory, increase M, i.e., L.
0
] , [ ] , 0 [ ], cos ) (
) (
) (
)[ ( ) ( ) (
0


s p
L
n
dr
S n n
Q
H
Q W E = =

=
Illustration of one iteration of
Illustration of one iteration of
Remez
Remez
exchange
exchange
H
d
(w)
P(w)
E(w)
Some issues in
Some issues in
Remez
Remez
exchange algorithm
exchange algorithm
Parks and McClellan [1972]: proposed this iterative algorithm,
assuming M and W() are known.
Lagrange Interpolation Algorithm:
How to approximately estimate M? (Kaiser)
If M cannot produce satisfactory increase or decrease M so that
the optimal FIR filter can be obtained.

+

=
+
=

= =
1
0
1
0
) ( where ), ( ) ( ) (
L
i j
j
j i
j
i
L
i
i i
C E C E



2
; 1
6 . 14
13 log 20

2 1 10 p s
f
f
M

= +

Optimal equiripple design


Optimal equiripple design
techniques
techniques
1. Preliminaries
2. Minimax criterion
3. Alternation theorem
4. Remez exchange design example
Remez
Remez
exchange design
exchange design

Ex.1
Ex.1
Design a linear phase FIR:
dB A
dB R
s s
p p
50 , 3 . 0
25 . 0 , 2 . 0
= =
= =


wp = 0.2*pi; ws = 0.3*pi; Rp = 0.25; As = 50;
delta1 = (10^(Rp/20)-1)/(10^(Rp/20)+1)
delta2 = (1+delta1)*(10^(-As/20))
deltaH = max(delta1,delta2); deltaL = min(delta1,delta2);
weights = [delta2/delta1 1]
deltaf = (ws-wp)/(2*pi)
M = ceil((-20*log10(sqrt(delta1*delta2))-13)/(14.6*deltaf)+1)
f = [0 wp/pi ws/pi 1]
m = [1 1 0 0];
h = remez(M-1,f,m,weights);
Example 1 (cont.)
Example 1 (cont.)
[db,mag,pha,grd,w] = freqz_m(h,[1]);
delta_w = 2*pi/1000; wsi=ws/delta_w+1; wpi = wp/delta_w;
Asd = -max(db(wsi:1:501)); Asd=47.8562
M = M+1; M=44
h = remez(M-1,f,m,weights);
[db,mag,pha,grd,w] = freqz_m(h,[1]);
Asd = -max(db(wsi:1:501)); Asd=48.2155
M = M+1; M=45
h = remez(M-1,f,m,weights);
Example 1 (cont.)
Example 1 (cont.)
[db,mag,pha,grd,w] = freqz_m(h,[1]);
Asd = -max(db(wsi:1:501)); Asd=48.8632
M = M+1; M=46
h = remez(M-1,f,m,weights);
[db,mag,pha,grd,w] = freqz_m(h,[1]);
Asd = -max(db(wsi:1:501)); Asd=49.8342
M = M+1; M=47
h = remez(M-1,f,m,weights);
[db,mag,pha,grd,w] = freqz_m(h,[1]);
Asd = -max(db(wsi:1:501)); Asd=51.0896
M; M=47
Remez
Remez
exchange design example (cont.)
exchange design example (cont.)
Remez
Remez
exchange design
exchange design

Ex.2
Ex.2
Design a linear phase bandpass filter:
dB A dB R
dB R dB A
s s p p
p p s s
60 , 8 . 0 , 1 , 65 . 0
1 , 35 . 0 , 60 , 2 . 0
2 2 2 2
1 1 1 1
= = = =
= = = =


ws1 = 0.2*pi; wp1 = 0.35*pi; wp2 = 0.65*pi; ws2 = 0.8*pi;
Rp = 1.0; As = 60;
delta1 = (10^(Rp/20)-1)/(10^(Rp/20)+1);
delta2 = (1+delta1)*(10^(-As/20));
deltaH = max(delta1,delta2); deltaL = min(delta1,delta2);
weights = [1 delta2/delta1 1];
delta_f =min((ws2-wp2)/(2*pi), (wp1-ws1)/(2*pi));
M = ceil((-20*log10(sqrt(delta1*delta2))-13)/(14.6*delta_f)+1)
f = [0 ws1/pi wp1/pi wp2/pi ws2/pi 1];
m = [0 0 1 1 0 0];
h = remez(M-1,f,m,weights);
Example 2
Example 2
dB A
dB R
dB R
dB A
s s
p p
p p
s s
60 , 8 . 0
1 , 65 . 0
1 , 35 . 0
60 , 2 . 0
2 2
2 2
1 1
1 1
= =
= =
= =
= =




Remez
Remez
exchange design
exchange design

Ex. 3
Ex. 3
Design a linear phase highpass filter:
dB R
dB A
p p
s s
5 . 0 , 75 . 0
50 , 6 . 0
= =
= =


ws = 0.6*pi; wp = 0.75*pi; Rp = 0.5; As = 50;
delta1 = (10^(Rp/20)-1)/(10^(Rp/20)+1);
delta2 = (1+delta1)*(10^(-As/20));
deltaH = max(delta1,delta2); deltaL = min(delta1,delta2);
weights = [1 delta2/delta1];
deltaf = (wp-ws)/(2*pi);
M = ceil((-20*log10(sqrt(delta1*delta2))-13)/(14.6*deltaf)+1);
% M must be odd
M = 2*floor(M/2)+1
f = [0 ws/pi wp/pi 1]
m = [0 0 1 1];
h = remez(M-1,f,m,weights);
Example
Example
3 (
3 (
cont)
cont)
dB R
dB A
p p
s s
5 . 0 , 75 . 0
50 , 6 . 0
= =
= =

You might also like