The Effect of Coefficient Quantization On The Performance of A Digital Filter
The Effect of Coefficient Quantization On The Performance of A Digital Filter
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 1/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
For a given set of filter specifications, we generally obtain the filter system
function, H (z), assuming that the filter coefficients can be represented with
infinite precision. However, when implementing the filter in the real world, we
have to use a finite number of bits to represent each coefficient of H (z). This
coefficient quantization can somehow change the location of the filter poles and
zeros.
Example 1
The transfer function of an Infinite Impulse Response (IIR) filter is given by:
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 2/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
M −1 −k
∑k=0 bk z
H (z) =
N −1 −k
∑ ak z
k=0
We can use the MATLAB ellip function to design an elliptic filter. For example,
[b, a]=ellip(7,0.5, 50, 0.3) gives a seventh-order elliptic lowpass filter with 0.5
dB ripples in the passband and 50 dB attenuation in the stopband. The
passband edge of the filter will be at the normalized frequency of 0.3π. The
coefficients of this filter are given in the following table. We will consider these
coefficients as the unquantized ones.
k bk(unquantized) ak(unquantized)
0 0.012218357882143 1.000000000000000
1 -0.009700754662078 -4.288900601525732
2 0.024350450826845 9.216957436091198
3 0.002532504848041 -12.195350561406707
4 0.002532504848041 10.633166152311462
5 0.024350450826845 -6.062798190498858
6 -0.009700754662078 2.098067018562072
7 0.012218357882143 -0.342340135743532
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 3/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
Figure 2 shows the poles (blue crosses) and zeros (red dots) of the transfer
function. Since the poles are inside the unit circle, the filter is stable
(https://ccrma.stanford.edu/~jos/fp/Stability_Revisited.html#sec:stability).
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 4/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
We will quantize the coefficients using one bit for the sign and nine bits for the
magnitude of the coefficients. Since all the bk coefficients are smaller than
2
−5
= 0.03125 , we can consider a scaling factor of
2
(number of bits+5)
= 2
(9+5)
= 16384 for these coefficients and achieve a
more accurate representation. The quantized bk coefficients are listed in Table
2. For example, to calculate the quantized value of b1 , we will first apply the
scaling factor and obtain:
(9+5) (9+5)
b1 × 2 = 0.012218357882143 × 2 = 200.1856
Now, we can round the result to 200. The binary representation of 200 , which
is 011001000 , will be used to implement the coefficients. However, we should
keep in mind that we need to interpret the results with a rescaling factor of
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 5/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
2
−(9+5)
. Then, the decimal equivalent of the quantized coefficient can be
obtained by multiplying 200 by 2−(9+5) which gives 0.0122.
In this particular example, with a scaling factor smaller than 2(9+5) , several bits
of the binary representation of the bk coefficients would be zero for all the
coefficients and we would lose the accuracy. For example, suppose that we
allocate nine bits to represent the fractional value of the bk coefficients. Hence,
we should apply a scaling factor of 29 which gives:
9 9
b1 × 2 = 0.012218357882143 × 2 = 6.2558
To quantize the ak coefficients, we note that the magnitude of the integer part
of these coefficients is smaller than 16. Hence, we can allocate four bits for the
integer part and five bits for the fractional part. As a result, the scaling factor of
the ak coefficients will be 25 . For example, with a2 = 9.216957436091198 ,
we have:
5 5
a2 × 2 = 9.216957436091198 × 2 = 294.9426 ≈ 295
Hence, the quantized decimal value for the coefficient will be 9.2188. Similarly,
we can find the quantized values of other ak coefficients as given in Table 2
below.
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 6/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
k bk(quantized) ak(quantized)
0 0.0122 1.0000
1 -0.0097 -4.2813
2 0.0244 9.2188
3 0.0025 -12.1875
4 0.0025 10.6250
5 0.0244 -6.0625
6 -0.0097 2.0938
7 0.0122 -0.3438
Figure 3 compares the frequency response of the quantized filter (the curve in
red) with that of the unquantized system (the curve in blue). We observe that
quantizing the coefficients has adversely affected the frequency response.
Figure 3. The frequency response of the quantized filter (in red) versus that of the unquantized system
(in blue).
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 7/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
The poles (blue crosses) and zeros (the red dots) of the quantized filter are
shown in Figure 4. As shown in this figure, two of the poles are moved out of
the unit circle and the quantized filter is unstable. This example shows that after
designing a filter, we need to examine the effect of the coefficient quantization.
If the quantized filter does not meet the target specifications, we need to
redesign the filter. In the rest of the article, we will see that implementing a high-
order filter as a cascade of second-order sections can significantly reduce the
sensitivity to the coefficient quantization.
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 8/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
To examine the sensitivity of the poles and zeros of a filter to the coefficient
quantization, let’s consider a polynomial, D(z), with N roots:
−k
D(z) = 1 + ∑ ak z
k=0
Equation 1
N N
−k −1
D(z) = 1 + ∑ ak z = ∏ (1 − p k z )
k=0 k=1
Where pk denotes the roots of the polynomial. With a finite number of bits to
represent each coefficient, we expect that ak will change to ak + Δak where
Δak is the error resulted from using a finite precision representation.
Consequently, we expect the roots of the polynomial to change from pk to
p k + Δp k . The error in the root location, Δp i , can be found as:
N N −k
p
i
Δp i = − ∑ Δak
N
k=1 ∏ (p i − p l )
l=1,l≠i
Equation 2
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 9/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
N −k
p
i
Fk =
N
∏l=1,l≠i (p i − p l )
Equation 3
This factor can be very large when the polynomial has other roots close to the
i th pole, i.e. pi − pl is small. In other words, when we have a cluster of roots,
the error in the root locations will be much higher for a given Δak . Since a
narrow band filter has generally tightly clustered roots, we expect that the
frequency response of these filters will be highly sensitive to the coefficient
quantization.
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 10/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
Δp i = − ∑ Fk Δak
k=1
Equation 4
To summarize, we should avoid clusters of poles and zeros and use low-order
filter sections. These two goals can be achieved by using single-pole sections
to implement a high-order filter. However, a filter has generally complex poles
and zeros and use of single-pole sections mandates complex arithmetic which
increases the computational complexity. The next best alternative is to use
second-order sections. In this case, we can pair complex-conjugate roots and
avoid the complex arithmetic. Since finding the cascade form of a high-order
filter involves tedious mathematics, we can use the MATLAB function tf2sos,
which stands for transfer function to second-order section, to obtain the
cascade form of a given transfer function.
Example 2
We will use the tf2sos function to convert the transfer function of Example 1 into
the cascade form. Then we will quantize the coefficients of these second-order
sections and compare the frequency response of the obtained structure with
that of the unquantized system.
The following lines of code define the transfer function of Example 1 and
convert that to second-order sections:
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 11/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
sos =
and:
G = 0.0122183579.
Each row of sos above gives the transfer function of one of the second-order
sections. The first three numbers of each row represent the numerator of the
corresponding second-order section and the second three numbers give its
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 12/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
denominator. For example, the second-order section obtained from the second
row is:
−1 −2
1.0000000000 + 0.0102799961z + 1.0000000000z
H2 (z) =
−1 −2
1.0000000000 − 1.2818759037z + 0.6209275764z
We will quantize the coefficients using one bit for the sign and nine bits for the
magnitude of the coefficients. We need to choose an appropriate scaling factor.
Since the coefficients of the second-order sections are less than 2, we will use
one bit for the integer part and eight bit for the fractional part, i.e. the scaling
factor will be 28 . Hence, we obtain the transfer function of the first section as:
−1
1.00000000 + 1.00000000z
H1 (z) =
−1
1.00000000 − 0.67968750z
The quantized transfer function of the other second-order sections will be:
−1 −2
1.00000000 + 0.01171875z + 1.00000000z
H2 (z) =
−1 −2
1.00000000 − 1.28125000z + 0.62109375z
−1 −2
1.00000000 − 0.81250000z + 1.00000000z
H3 (z) =
−1 −2
1.00000000 − 1.17968750z + 0.84375000z
−1 −2
1.00000000 − 0.99218750z + 1.00000000z
H4 (z) =
−1 −2
1.00000000 − 1.14843750z + 0.96093750z
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 13/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
Figure 5. The frequency response of the cascade structure (in red) versus that of the unquantized
system (in blue).
The reader can easily use MATLAB roots() function to verify that the poles of
the quantized cascade structure are inside the unit circle and the system is
stable. This example shows that implementing a high-order filter as a cascade
of second-order sections can significantly reduce the sensitivity to the
coefficient quantization.
Summary
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 14/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
When implementing a digital filter in the real world, we have to use a finite
number of bits to represent each coefficient of H (z) .
The frequency response of the quantized filter might be quite different from
that of the original design.
Implementing a high-order filter as a cascade of second-order sections
can significantly reduce the sensitivity to the coefficient quantization.
Supporting Information
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 15/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 16/17
11/19/2017 The Effect of Coefficient Quantization on the Performance of a Digital Filter
https://www.allaboutcircuits.com/technical-articles/effect-coefficient-quantization-performance-digital-filter/ 17/17