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
- Filter Design Principles
Choosing and designing digital filters - IIR Filters
Infinite Impulse Response digital filters - Kalman Filter
Optimal state estimation for linear systems - Madgwick Filter - Orientation Estimation
Gradient descent orientation filter for IMU sensor fusion - Mahony Filter - Orientation Estimation
Complementary filter with PI controller for IMU sensor fusion - Median Filter
Non-linear filtering for noise reduction - Sensor Fusion with Kalman Filters
Combining multiple sensors using Kalman filtering