FIR Filters

Sources:

  1. James McClellan, Ronald Schafer & Mark Yoder. (2015). FIR Filters. DSP First (2nd ed., pp. 147-193). Pearson.

Discrete-Time Systems

  • Sequence: a discrete-time signal1.

  • Discrete-time system or filter2: a function for transforming one sequence, called the input signal, into another sequence called the output signal.

    Block-diagram representation of a discrete-time system

In general, we represent the operation of a discrete-time system by the notation (1)x[n]Ty[n] Or (2)y[n]=T(x[n])

  • x: input sequence
  • y: output sequence
  • T: the operator, aka computational process, mapping or function.

y[n]=(x[n])2

The Running-Average Filter

  • A running average or moving average system: the output is the average of some consecutive values of the input. Such as (3)y[n]=k=0Mx[nk] You can also define a running average as y[n]=k=0Mx[n+k], y[n]=k=0Mx[n1+k] or whatever.

  • The equation like (3) is called a difference equation. It is a complete description of the FIR system because we can use (3) to compute the entire output signal for all index values <n<.

  • A filter that uses only the present and past values of the input is called a causal filter. Thus (3) is a causal running average.

Example

For a input sequence x[n] with support set x[0],x[1],x[2]=2,4,6:

Figure 5.2 a

we define an output sequence y[n]:

Figure 5.2 b (4)y[n]=x[n]+x[n+1]+x[n+2]3

with y[0]=13(x[0]+x[1]+x[2])y[1]=13(x[1]+x[2]+x[3])

(4) is the difference equation of this causal running average system.

The General FIR Filter

Definition

We define a Mth-order weighted running average/FIR filter of M+1 samples. (5)y[n]=k=0Mbkx[nk], which can be extended to b0x[n]+b1x[n1]++bMx[nM].

  • FIR system: Finite Input Response system. Because the impulse response sequence h[n] is finite(Illustrated later).
    • x[n],y[n] can be infinite since n can be infinte: <n<. But for FIR, the h[n] must be finite.
  • The 3-point noncausal running average (???) is the case where M=2 and bk=1/3 in (5).
  • the coefficients bk are fixed numbers.
  • According to (5), an FIR filter is causal.
    • Note that a noncausal system can be represented by altering (5) to include negative values of the summation index k.
  • Usually the bk coefficients are not all the same, and then we say that (5) is "weighted".
  • It follows from (5) that the computation of y[n] involves the samples x[] for =n,n1,n2,,nM (i.e., x[n],x[n1],x[n2], etc):

A second defnition: (6)y[n]==nMnbnx[],

which can be extended to bMx[nM]+bM1x[nM+1]++b0x[n].

Example

Figure 5.4 llustrates how the causal FIR filter uses x[n] and the past M samples to compute the output.

Figure 5.4
  • the weighted average is calculated over the (gray) sliding window of M+1 samples.
  • When the input signal x[l] has finite length (N samples), the sliding window runs onto and off of the input data, so the resulting output signal also has finite length.

The Unit Impulse Response and Convolution

In this section, we introduce three new ideas: the unit impulse sequence, the unit impulse response, and the convolution sum.

We show that the impulse response provides a complete characterization of the FIR filter, because the convolution sum gives a formula for computing the output from the input when the unit impulse response is known.

Unit Impulse Sequence

The unit impulse: δ[n]={1n=00n0

This notation is also known as the Kronecker delta function.

Shifted Unit Impulse Sequence

Here is the tabular of δ[n] and δ[n2]

Unit Impulse Sequence Table

For a shifted unit impulse such as (7)δ[n2] A shifted unit impulse


The shifted impulse is a concept that is very useful in representing signals and systems. For example, we can show that the formula x[n]=2δ[n]+4δ[n1]+6δ[n2]+4δ[n3]+2δ[n4] is equivalent to defining x[n] by tabulating its five nonzero values:

Unit Impulse Sequence Table 2

It turns out that any sequence3 can be represented by a sum of scaled shifted impulses . The equation x[n]=kx[k]δ[nk]=+x[1]δ[n+1]+x[0]δ[n]+x[1]δ[n1]+x[2]δ[n2]+ is true if k ranges over all the nonzero values of the sequence x[n].

Unit Impulse Response Sequence

  • The output from a filter is often called the response to the input.

  • When the input is the unit impulse, δ[n], the output is called the unit impulse response (Or impulse response, with unit being understood).

  • Notation of unit impulse response: h[n].

  • When the input to the FIR filter (5) is a unit impulse sequence, x[n]=δ[n], the output is the (unit) impulse response h[n]. Substituting x[n]=δ[n] in (5) gives the output y[n]=h[n]: h[n]=k=0Mbkδ[nk]={bnn=0,1,2,,M0 otherwise 

    Note that because each δ[nk] is nonzero only when nk=0, or n=k, the impulse response is:

    Unit impulse response and coefficients
  • In other words, the impulse response h[n] of the FIR filter is identical to the sequence of difference equation coefficients. So the FIR filter is completely defined by the impulse response.

    • In following chapter, we'll show that this characterization is also true for the much broader class of linear time-invariant (LTI) systems.
  • Since h[n]=0 for n<0 and for n>M, the "length"4 of the impulse response sequence h[n] is finite. This is why the system (5) is called a FIR system.

The Unit-Delay System

One important system is the operator that performs a delay or shift by an amount n0 y[n]=x[nn0]

When n0=1, the system is called a unit delay.

  • The delay system is actually the simplest of FIR filters. y[n]=b0x[n]+b1x[n1]+b2x[n2]++bn0x[nn0]=(0)x[n]+(0)x[n1]+(0)x[n2]++(1)x[nn0]=x[nn0]

  • The impulse response of the delay system is obtained by substituting δ[n] for x[n].

  • (7) is a delay-by-2 system y[n]=x[n2] with coefficients {bk}= {0,0,1}, its impulse response is: h[n]=δ[nn0]=δ[n2]={1n=20n2

FIR Filters and Convolution

Since the filter coefficients in (5) are identical to the impulse response value h[n]. We can express a FIR filter in terms of the input and the impulse response. This is called convolution sum: (8)y[n]=k=0Mh[k]x[nk] Here we replace bk in (5) with h[k].

  • The terminology convolution emphasizes that it's an operation between two sequences.

  • We use a star () to represent the operation of evaluating (5.13) for < n< by writing (9)y[n]=h[n]x[n] which is read as "the output sequence y[n] is obtained by convolving the impulse response h[n] with the input sequence x[n]."

Later, in Section 5-7, we will prove that convolution is the fundamental input-output algorithm for a large class of very useful filters that includes FIR filters as a special case. We will show that a general form of convolution that also applies to infinite-length signals is y[n]=h[n]x[n](10)=k=h[k]x[nk].

This convolution sum (10) has infinite limits to accomodate impulse responses of infinite length, but reduces to (8) when h[n]=0 for n<0 and n>M.

The Length of a Convolution

If x[n] is nonzero only in the interval 0nLx1, then for a causal FIR filter having an impulse response of length Lh=M+1 samples (because the impulse response is the sequence: h[0], h[1], ..., h[M]), the corresponding output y[n], which is the convolution of h[n] with x[n], can be nonzero only when n0 and nMLx1, or equivalently, the support set of y[n] is the interval 0nLx+M1. Thus the length of y[n] is (11)Ly=Lx+Lh1

通俗地说, y[n]长度 = x[n]长度 + h[n]长度 - 1.

以下面example为例, x[n]的长度是11(Lx=11), 最后一个非0值位于下标10(Lx1), 但由于M=3, 因此以x[10]为起始点的M个值 x[10],x[11],x[12]的running average 还是非零: y[12]=x[12]h[12]0, convolution一直持续到下标12(Lx1+M).

而convolution是从下标0开始的(Px[2]+x[1]+x[1]3), 因此convolution y[n]从下标0一直持续到下标12(Lx1+M). 其长度为Lx+M=Ly=Lx+Lh1.

When the signals start at n=0, it is possible to use the synthetic multiplication table to prove that the formula (11) is true. Since the length of x[n] is Lx, the last nonzero signal value is x[Lx1]. Likewise, for h[n] where h[Lh1] is the last nonzero value. In the figure, the row for h[0]x[n] starts at n=0 and ends at n=Lx1, while the row for h[Lh1]x[n(Lh1)] ends at n=(Lx1)+(Lh1). After summing down the columns, we see that the convolution result y[n] starts at n=0 and ends at n=Lh+Lx2, so the length of y[n] is Lx+Lh1. Problem P-5.6 considers the general case where the signal x[n] begins at sample N1 and ends at sample N2.

Example

Figure 5.5

Given impulse response h[n]=13δ[n]+13δ[n1]+13δ[n2] and input x[n]={1n=0,1,2,,100 otherwise .

The output y[n]=h[n]x[n] has length Ly=11+31=13.

Filtering the Unit-Step Signal

In previous sections, we have described the FIR filtering of finite-length signals.

But the input signal can also have infinite duration.

An example is the unit-step signal which is zero for n<0 and "turns on" at n=0 u[n]={0n<01n0

The symbol u[n] is reserved for the unit step.

So when we want the input signal to be the unit step we write x[n]=u[n], and the output of an Mth -order FIR filter would be y[n]==nMnbnu[] if we use the form in (5). Since the FIR filter is causal and the unit step starts at n=0, the output is zero for n<0. Determining the output for n0 can be done by writing out terms

Property of Convolution

convolution is:

  1. commutative: y[n]=h[n]x[n]=x[n]h[n]

//Proof: TODO


  1. See↩︎

  2. Strictly speaking, a filter is a system that is designed to remove some component or modify some characteristic of a signal, but often the two terms are used interchangeably.↩︎

  3. Remember that a sequence is a discrete-time signal.↩︎

  4. 这里所谓"length"指的是support set的长度. n可以是无限的, 因此x[n],y[n],h[n]也可以是无限的. 但是它们的suport set未必无限. 特别是h[n]的长度已经被(8)固定为M+1.↩︎