A digital filter is characterized by its
transfer function, or equivalently, its
difference equation. Mathematical analysis of the transfer function can describe how it will respond to any input. As such, designing a filter consists of developing specifications appropriate to the problem (for example, a second-order low-pass filter with a specific cut-off frequency), and then producing a transfer function that meets the specifications. The
transfer function for a linear, time-invariant, digital filter can be expressed as a transfer function in the
Z-domain; if it is causal, then it has the form: :H(z) = \frac{B(z)}{A(z)} = \frac{{b_{0}+b_{1}z^{-1}+b_{2}z^{-2} + \cdots + b_{N}z^{-N}}}{{1+a_{1}z^{-1}+a_{2}z^{-2} + \cdots +a_{M}z^{-M}}} where the order of the filter is the greater of
N or
M. See
Z-transform's LCCD equation for further discussion of this transfer function. This is the form for a
recursive filter, which typically leads to an
infinite impulse response (IIR) behaviour, but if the
denominator is made equal to
unity, i.e. no feedback, then this becomes a
finite impulse response (FIR) filter.
Analysis techniques A variety of mathematical techniques may be employed to analyze the behavior of a given digital filter. Many of these analysis techniques may also be employed in designs, and often form the basis of a filter specification. Typically, one characterizes filters by calculating how they will respond to a simple input such as an impulse. One can then extend this information to compute the filter's response to more complex signals.
Impulse response The
impulse response, often denoted h[k] or h_k, is a measurement of how a filter will respond to the
Kronecker delta function. For example, given a difference equation, one would set x_0 = 1 and x_k = 0 for k \ne 0 and evaluate. The impulse response is a characterization of the filter's behavior. Digital filters are typically considered in two categories:
infinite impulse response (IIR) and
finite impulse response (FIR). In the case of linear time-invariant FIR filters, the impulse response is exactly equal to the sequence of filter coefficients, and thus: :\ y_n= \sum_{k=0}^{N} b_{k} x_{n-k} =\sum_{k=0}^{N} h_{k} x_{n-k} IIR filters on the other hand are recursive, with the output depending on both current and previous inputs as well as previous outputs. The general form of an IIR filter is thus: :\ \sum_{m=0}^{M} a_{m}y_{n-m} = \sum_{k=0}^{N} b_{k} x_{n-k} Plotting the impulse response reveals how a filter responds to a sudden, momentary disturbance. An IIR filter is always recursive. While it is possible for a recursive filter to have a finite impulse response, a non-recursive filter always has a finite impulse response. An example is the moving average (MA) filter, which can be implemented both recursively and non recursively.
Difference equation In
discrete-time systems, the digital filter is often implemented by converting the transfer function to a
linear constant-coefficient difference equation (LCCD) via the
Z-transform. The discrete
frequency-domain transfer function is written as the ratio of two polynomials. For example: :H(z) = \frac{(z+1)^2} {(z-\frac{1}{2}) (z+\frac{3}{4})} This is expanded: :H(z) = \frac{z^2+ 2z +1} {z^2 +\frac{1}{4} z - \frac{3}{8}} and to make the corresponding filter
causal, the numerator and denominator are divided by the highest order of z: : H(z) = \frac{1 + 2z^{-1} +z^{-2}} {1 +\frac{1}{4} z^{-1} - \frac{3}{8} z^{-2}} = \frac{Y(z)}{X(z)} The coefficients of the denominator, a_{k}, are the 'feed-backward' coefficients and the coefficients of the numerator are the 'feed-forward' coefficients, b_{k}. The resultant linear difference equation is: : y[n] = -\sum_{k=1}^{M} a_{k} y[n-k] + \sum_{k=0}^{N} b_{k} x[n-k] or, for the example above: : \frac{Y(z)}{X(z)} = \frac{1 + 2z^{-1} +z^{-2}} {1 +\frac{1}{4} z^{-1} - \frac{3}{8} z^{-2}} rearranging terms: : \Rightarrow (1 +\frac{1}{4} z^{-1} - \frac{3}{8} z^{-2}) Y(z) = (1 + 2z^{-1} +z^{-2}) X(z) then by taking the inverse
z-transform: : \Rightarrow y[n] + \frac{1}{4} y[n-1] - \frac{3}{8} y[n-2] = x[n] + 2x[n-1] + x[n-2] and finally, by solving for y[n]: : y[n] = - \frac{1}{4} y[n-1] + \frac{3}{8} y[n-2] + x[n] + 2x[n-1] + x[n-2] This equation shows how to compute the next output sample, y[n], in terms of the past outputs, y[n-p], the present input, x[n], and the past inputs, x[n-p]. Applying the filter to an input in this form is equivalent to a Direct Form I or II (see below) realization, depending on the exact order of evaluation. In plain terms, for example, as used by a computer programmer implementing the above equation in code, it can be described as follows: y = the output, or filtered value x = the input, or incoming raw value n = the sample number, iteration number, or time period number and therefore: y[n] = the current filtered (output) value y[n-1] = the last filtered (output) value y[n-2] = the 2nd-to-last filtered (output) value x[n] = the current raw input value x[n-1] = the last raw input value x[n-2] = the 2nd-to-last raw input value ==Filter design==