OpenStax-CX module: m689 FIR Filter Design by Frequency Sampling or Interpolation * C. Sidney Burrus This work is produced by OpenStax-CX and licensed under the Creative Commons Attribution License 2. Since samples of the frequency response of an FIR lter can be calculated by taking the DFT of the impulse response h (n), one could propose a lter design method consisting of taking the inverse DFT of samples of a desired frequency response. This can indeed be done and is called frequency sampling design. The resulting lter has a frequency response that exactly interpolates the given samples, but there is no explicit control of the behavior between the samples [], [2]. Three methods for frequency sampling design are:. Take the inverse DFT (perhaps using the FFT) of equally spaced samples of the desired frequency response. Care must be taken to use the correct phase response to obtain a real valued causal h (n) with reasonable behavior between sample response. This method works for general nonlinear phase design as well as for linear phase. 2. Derive formulas for the inverse DFT which take the symmetries, phase, and causality into account. It is interesting to notice these analysis and design formulas turn out to be the discrete cosine and sine transforms and their inverses. 3. Solve the set of simultaneous linear equations that result from calculating the sampled frequency response from the impulse response. This method allows unevenly spaced samples of the desired frequency response but the resulting equations may be ill conditioned. Frequency Sampling Filter Design by Inverse DFT The most direct frequency sampling design method is to simply take the inverse DFT of equally spaced samples of the desired complex frequency response H d (ω k ). This is done by ( ) 2π H d k e j2πnk/ () where care must be taken to insure that the real and imaginary parts (or magnitude and phase) of H d (ω k ) satisfy the symmetry conditions that give a real, causal h (n). This method will allow a general complex H (ω) as well as a linear phase. In most cases, it is easier to specify proper and consistent samples if it is the magnitude and phase that are set rather than the real and imaginary parts. For example, it is important that the desired phase be consistent with the specied length being even or odd as is given in Equation 28 from FIR Digital Filters and Equation 24 from FIR Digital Filters. * Version.2: ov 2, 29 :4 pm -6 http://creativecommons.org/licenses/by/2./
OpenStax-CX module: m689 2 Since the frequency sampling design method will always produce a lter with a frequency response that interpolates the specied samples, the results of inappropriate phase specications will show up as undesired behavior between the samples. 2 Frequency Sampling Filter Design by Formulas When equally spaced samples of the desired frequency response are used, it is possible to derive formulas for the inverse DFT and, therefore, for the lter coecients. This is because of the orthogonal basis function of the DFT. These formulas can incorporate the various constraints of a real h (n) and/or linear phase and eliminate the problems of inconsistency in specifying H (ω k ). To develop explicit formulas for frequency-sampling design of linear-phase FIR lters, a direct use of the inverse DFT is most straightforward. When H (ω) has linear phase, () may be simplied using the formulas for the four types of linear-phase FIR lters. 2. Type. Odd Sampling Samples of the frequency response Equation 29 from FIR Digital Filters for the lter where is odd, L =, and M = ( ) /2, and where there is a frequency sample at ω = is given as 2h (n) cos (2π (M n) k/) + h (M). (2) Using the amplitude function A (ω), dened in Equation 28 from FIR Digital Filters, of the form (2) and the IDFT () gives for the impulse response or e j2πmk/ A k e j2πnk/ (3) A k e j2π(n M)k/. (4) Because h (n) is real, A k and (4) becomes [ ] A + 2A k cos (2π (n M) k/). (5) k= Only M + of the h (n) need be calculated because of the symmetries in Equation 27 from FIR Digital Filters. This formula calculates the impulse response values h (n) from the desired frequency samples A k and requires M 2 operations rather than 2. An interesting observation is that not only are (2) and (5) a pair of analysis and design formulas, they are also a transform pair. Indeed, they are of the same form as a discrete cosine transform (DCT). 2.2 Type 2. Odd Sampling A similar development applied to the cases for even from Equation 36 from FIR Digital Filters gives the amplitude frequency response samples as /2 2h (n) cos (2π (M n) k/) (6)
OpenStax-CX module: m689 3 with the design formula of A + /2 k= 2A k cos (2π (n M) k/) (7) which is of the same form as (5), except that the upper limit on the summation recognizes as even and A /2 equals zero. 2.3 Even Sampling The schemes just described use frequency samples at ω = 2πk/, k =,, 2,..., (8) which are equally-spaced samples starting at ω =. Another possible pattern for frequency sampling that allows design formulas has no sample at ω =, but uses equally-spaced samples located at ω = (2k + ) π/, k =,, 2,..., (9) This form of frequency sampling is more dicult to relate to the DFT than the sampling of (8), but it can be done by stretching A k and taking a 2-length DFT []. 2.4 Type. Even Sampling The two cases for odd and even lengths and the two for samples at zero and not at zero frequency give a total of four cases for the frequency-sampling design method applied to linear- phase FIR lters of Types and 2, as dened in the section Linear-Phase FIR Filters. For the case of an odd length and no zero sample, the analysis and design formulas are derived in a way analogous to (2) and (7) to give 2h (n) cos (2π (M n) (k + /2) /) + h (M) () The design formula becomes [ ] 2A k cos (2π (n M) (k + /2) /) + A M cosπ (n M) () 2.5 Type 2. Even Sampling The fourth case, for an even length and no zero frequency sample, gives the analysis formula and the design formula /2 2h (n) cos (2π (M n) (k + /2) /) (2) /2 2A k cos (2π (n M) (k + /2) /) (3) These formulas in (5), (7), (), and (3) allow a very straightforward design of the four frequency-sampling cases. They and their analysis companions in (2), (6), (), and (2) also are the four forms of discrete cosine and inverse-cosine transforms. Matlab programs which implement these four designs are given in the appendix.
OpenStax-CX module: m689 4 2.6 Type 3. Odd Sampling The design of even-symmetric linear-phase FIR lters of Types and 2 in the section Linear-Phase FIR Filters have been developed here. A similar development for the odd-symmetric lters, Types 3 and 4, can easily be performed with the results closely related to the discrete sine transform. The Type 3 analysis and design results using the frequency sampling scheme of (8) are and b= 2h (n) sin (2π (M n) k/) (4) [ M ] 2A k sin (2π (M n) k/) k= (5) 2.7 Type 4. Odd Sampling For Type 4 they are and /2 k= /2 2h (n) sin (2π (M n) k/) (6) 2A k sin (2π (M n) k/) + A /2 sin (π (M n)). (7) 2.8 Type 3. Even Sampling Using the frequency sampling scheme of (9), the Type 3 equations become and 2h (n) sin (2π (M n) (k + /2) /) (8) [ 2A k sin (2π (M n) (k + /2) /) ] (9) 2.9 Type 4. Even Sampling For Type 4 they are /2 2h (n) sin (2π (M n) (k + /2) /) (2)
OpenStax-CX module: m689 5 and /2 2A k sin (2π (M n) (k + /2) /). (2) These Type 3 and 4 formulas are useful in the design of dierentiators and Hilbert transformers [,2,9,3] directly and as the base of the discrete least-squared-error methods in the section Discrete Frequency Samples of Error. 3 Frequency Sampling Design of FIR Filters by Solution of Simultaneous Equations A direct way of designing FIR lters from samples of a desired amplitude simply takes the sampled denition of the frequency response Equation 29 from FIR Digital Filters as A (ω k ) = or the reduced form from Equation 37 from FIR Digital Filters as 2h (n) cosω k (M n) + h (M) (22) where A (ω k ) = M a (n) cos (ω k (M n)) (23) a (n) = { 2h (n) for n M h (M) for n = M otherwise for k =,, 2,..., M and solves the M + simultaneous equations for a (n) or equivalently, h (n). Indeed, this approach can be taken with general non-linear phase design from Indeed, this approach can be taken with general non-linear phase design from H (ω k ) = h (n) e jω kn for k =,, 2,, which gives equations with unknowns. This design by solving simultaneous equations allows non-equally spaced samples of the desired response. The disadvantage comes from the numerical calculations taking considerable time and being subject to inaccuracies if the equations are ill-conditioned. The frequency sampling design method is interesting but is seldom used for direct design of lters. It is sometimes used as an interpolating method in other design procedures to nd h (n) from calculated A (ω k ). It is also used as a basis for a least squares design method discussed in the next section. 4 Examples of Frequency Sampling FIR Filter Design To show some of the characteristics of FIR lters designed by frequency sampling, we will design a Type., length-5 FIR low pass lter. Desired amplitude response was one in the pass band and zero in the stop band. The cuto frequency was set at approximately f =.35 normalized. Using the formulas (5), (7), (), and (3), we got impulse responses h (n), which are use to generate the results shown in Figures Figure 26 and Figure 26. (24) (25)
OpenStax-CX module: m689 6 The Type, length-5 lter impulse response is: h =.99.639 4.494 7 4.494.639.99 (26) The amplitude frequency response and zero locations are shown in Figure 26a.5 Type. Frequency samples with odd spacing.2.4.6.8.5.2.4.6.8.5 Type 2. Frequency samples with odd spacing Type. Frequency samples with even spacing.2.4.6.8.5 Type 2. Frequency samples with even spacing.2.4.6.8 ormalized Frequency Imaginary part of z Imaginary part of z Imaginary part of z Imaginary part of z Zero Locations 2 2 2 2 2 2 2 2 Figure 26: Frequency Responses and Zero Locations of Length-5 and 6 FIR Filters Designed by Frequency Sampling We see a good lowpass lter frequency response with the actual amplitude interpolating the desired values at 8 equally spaced points. otice there is considerable overshoot near the cuto frequency. This is characteristic of frequency sampling designs and is a sort of Gibbs phenomenon" but is even worse than that in a Fourier series expansion of a discontinuity. This Gibbs phenomenon could be reduced by using unequally spaced samples and designing by solving simultaneous equations. Imagine sampling in the pass
OpenStax-CX module: m689 7 and stop bands of Figure 8c from FIR Digital Filters but not in the transitionband. The other responses and zero locations show the results of dierent interpolation locations and lengths. ote the zero at - for the even lters. Examples of longer lters and of highpass and bandpass frequency sampling designs are shown in Figure 26. ote the dierence of even and odd distributions of samples with with or without an interpolation point at zero frequency. ote the results of dierent ideal lters and Type or 2. Also note the relationship of the amplitude response and zero locations.
OpenStax-CX module: m689 8 Type. Length 2 Lowpass FIR Filter.5.2.4.6.8 Type 2. Length 2 Lowpass FIR Filter.5.2.4.6.8 Type. FIR Length 2 Highpass FIR Filter.5.2.4.6.8 Type 2. Length 2 Bandpass FIR Filter.5.2.4.6.8 ormalized Frequency Imaginary part of z Imaginary part of z Imaginary part of z Imaginary part of z Zero Location 2 2 2 2 2 2 2 2 Figure 26: Frequency Response and Zero Locations of FIR Filters Designed by Frequency Sampling
OpenStax-CX module: m689 9 References [] T. W. Parks and C. S. Burrus. Digital Filter Design. John Wiley & Sons, ew York, 987. [2] L. M. Smith and B. W. Bomar. Least squares and related techniques. In Wai-Kai Chen, editor, The Circuits and Filters Handbook, chapter 82.2, page 256282;2572. CRC Press and IEEE Press, Boca Raton, 995.