FIR Filters

Finite Impulse Response filters - always stable, linear phase possible.

Definition

$$ y[n] = \sum_{k=0}^{M-1} b_k x[n-k] $$

Design Methods

Window Method

 1from scipy import signal
 2import numpy as np
 3
 4# Design lowpass FIR filter
 5numtaps = 51  # Filter order + 1
 6cutoff = 0.3  # Normalized frequency (0 to 1)
 7
 8# Using window method
 9h = signal.firwin(numtaps, cutoff, window='hamming')
10
11# Apply filter
12y = signal.lfilter(h, 1.0, x)

Frequency Sampling

1# Design filter from frequency response
2freqs = [0, 0.2, 0.3, 1.0]
3gains = [1, 1, 0, 0]  # Lowpass
4h = signal.firwin2(numtaps, freqs, gains)

Advantages

  • Always stable
  • Linear phase possible (no phase distortion)
  • Easy to design

Disadvantages

  • Higher order needed vs IIR
  • More computation

Further Reading

Related Snippets