<< Chapter < Page Chapter >> Page >

Express the unit-sample response of a FIR filter in terms of difference equation coefficients. Note that thecorresponding question for IIR filters is far more difficult to answer: Consider the example .

The difference equation for an FIR filter has the form

y n m 0 q b m x n m
The unit-sample response equals
h n m 0 q b m δ n m
which corresponds to the representation described in a problem of a length- q boxcar filter.

Got questions? Get instant answers now!

For IIR systems, we cannot use the DFT to find the system's unit-sample response: aliasing of the unit-sampleresponse will always occur. Consequently, we can only implement an IIR filter accurately in the timedomain with the system's difference equation. Frequency-domain implementations are restricted to FIR filters.

Another issue arises in frequency-domain filtering that isrelated to time-domain aliasing, this time when we consider the output. Assume we have an input signal having duration N x that we pass through a FIR filter having a length- q 1 unit-sample response. What is the duration of the output signal? The difference equation for this filter is

y n b 0 x n b q x n q
This equation says that the output depends on current and past input values, with the input value q samples previous defining the extent of the filter's memory of past input values. For example, the output at index N x depends on x N x (which equals zero), x N x 1 , through x N x q . Thus, the output returns to zero only after the last input value passes through the filter's memory. As the input signal's last value occurs atindex N x 1 , the last nonzero output value occurs when n q N x 1 or n q N x 1 . Thus, the output signal's duration equals q N x .

In words, we express this result as "The output's duration equals the input's duration plus the filter's duration minusone.". Demonstrate the accuracy of this statement.

The unit-sample response's duration is q 1 and the signal's N x . Thus the statement is correct.

Got questions? Get instant answers now!

The main theme of this result is that a filter's output extends longer than either its input or itsunit-sample response. Thus, to avoid aliasing when we use DFTs, the dominant factor is not the duration of input or of theunit-sample response, but of the output. Thus, the number of values at which we must evaluate the frequency response's DFTmust be at least q N x and we must compute the same length DFT of the input. To accommodate a shorter signal than DFT length, we simply zero-pad the input: Ensure that for indices extending beyond the signal's duration that the signal iszero. Frequency-domain filtering, diagrammed in [link] , is accomplished by storing the filter's frequency response as the DFT H k , computing the input's DFT X k , multiplying them to create the output's DFT Y k H k X k , and computing the inverse DFT of the result to yield y n .

To filter a signal in the frequency domain, first compute the DFT of the input, multiply the result by the sampled frequencyresponse, and finally compute the inverse DFT of the product. The DFT's length must be at least the sum of the input's and unit-sample response's duration minusone. We calculate these discrete Fourier transforms using the fast Fourier transform algorithm, of course.

Before detailing this procedure, let's clarify why so many new issues arose in trying to develop afrequency-domain implementation of linear filtering. The frequency-domain relationship between a filter's inputand output is always true: Y 2 f H 2 f X 2 f . The Fourier transforms in this result are discrete-time Fourier transforms; for example, X 2 f n x n 2 f n . Unfortunately, using this relationship to perform filtering is restricted to the situation when we have analyticformulas for the frequency response and the input signal. The reason why we had to "invent" the discrete Fourier transform(DFT) has the same origin: The spectrum resulting from the discrete-time Fourier transform depends on the continuous frequency variable f . That's fine for analytic calculation, but computationally we would have to make anuncountably infinite number of computations.

Did you know that two kinds of infinities can be meaningfully defined? A countably infinite quantity means that it can be associated with a limiting processassociated with integers. An uncountably infinite quantity cannot be so associated. The number of rational numbers is countably infinite (the numerator and denominatorcorrespond to locating the rational by row and column; the total number so-located can be counted, voila!); the number ofirrational numbers is uncountably infinite. Guess which is "bigger?"
The DFT computes the Fourier transform at a finite set of frequencies — samples the true spectrum— which can lead to aliasing in the time-domain unless we sample sufficiently fast. The sampling interval here is 1 K for a length- K DFT: faster sampling to avoid aliasing thus requires a longer transformcalculation. Since the longest signal among the input, unit-sample response and output is the output, it is thatsignal's duration that determines the transform length. We simply extend the other two signals with zeros (zero-pad) tocompute their DFTs.

Suppose we want to average daily stock prices taken over last year to yield a running weekly average(average over five trading sessions). The filter we want is a length-5 averager (as shown in the unit-sample response ), and the input's duration is 253 (365 calendar days minusweekend days and holidays). The output duration will be 253 5 1 257 , and this determines the transform length we need to use. Because we want to use the FFT, we are restricted topower-of-two transform lengths. We need to choose any FFT length that exceeds the required DFT length. As it turns out,256 is a power of two ( 2 8 256 ), and this length just undershoots our required length. To use frequency domain techniques, we must uselength-512 fast Fourier transforms.

The blue line shows the Dow Jones Industrial Average from 1997, and the red one the length-5 boxcar-filtered resultthat provides a running weekly of this market index. Note the "edge" effects in the filtered output.

[link] shows the input and the filtered output. The MATLAB programs that compute the filteredoutput in the time and frequency domains are

Time Domain h = [1 1 1 1 1]/5; y = filter(h,1,[djia zeros(1,4)]); Frequency Domainh = [1 1 1 1 1]/5;DJIA = fft(djia, 512); H = fft(h, 512);Y = H.*X; y = ifft(Y);

The filter program has the feature that the length of its output equals the length ofits input. To force it to produce a signal having the proper length, the program zero-pads the inputappropriately.
MATLAB's fft function automatically zero-pads its input if the specified transformlength (its second argument) exceeds the signal's length. The frequency domain result will have a smallimaginary component — largest value is 2.2 -11 — because of the inherent finite precision nature of computerarithmetic. Because of the unfortunate misfit between signal lengths and favored FFT lengths, the number of arithmeticoperations in the time-domain implementation is far less than those required by the frequency domain version: 514versus 62,271. If the input signal had been one sample shorter, the frequency-domain computations would have beenmore than a factor of two less (28,696), but far more than in the time-domain implementation.

An interesting signal processing aspect of this example is demonstrated at the beginning and end of theoutput. The ramping up and down that occurs can be traced to assuming the input is zero before it begins and after itends. The filter "sees" these initial and final values as the difference equation passes over the input. These artifacts canbe handled in two ways: we can just ignore the edge effects or the data from previous and succeeding years' last and firstweek, respectively, can be placed at the ends.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Fundamentals of electrical engineering i. OpenStax CNX. Aug 06, 2008 Download for free at http://legacy.cnx.org/content/col10040/1.9
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Fundamentals of electrical engineering i' conversation and receive update notifications?

Ask