IIR Filters

Infinite Impulse Response filters - efficient but can be unstable.

Definition

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

Design Methods

Butterworth (Maximally Flat)

 1from scipy import signal
 2
 3# Design 4th-order Butterworth lowpass
 4order = 4
 5cutoff = 0.3  # Normalized frequency
 6b, a = signal.butter(order, cutoff, btype='low')
 7
 8# Apply filter
 9y = signal.lfilter(b, a, x)
10
11# Or use filtfilt for zero-phase
12y = signal.filtfilt(b, a, x)

Chebyshev (Steeper Rolloff)

1# Chebyshev Type I (ripple in passband)
2b, a = signal.cheby1(order, rp=0.5, Wn=cutoff)
3
4# Chebyshev Type II (ripple in stopband)
5b, a = signal.cheby2(order, rs=40, Wn=cutoff)

Elliptic (Steepest Rolloff)

1b, a = signal.ellip(order, rp=0.5, rs=40, Wn=cutoff)

Advantages

  • Lower order than FIR for same specs
  • Less computation

Disadvantages

  • Can be unstable
  • Non-linear phase
  • Feedback can accumulate errors

Stability Check

1# Check if poles are inside unit circle
2poles = np.roots(a)
3is_stable = np.all(np.abs(poles) < 1)

Further Reading

Related Snippets