FIR Filter Theory
A comprehensive guide to Finite Impulse Response filters ā from mathematical foundations to practical design
What is a FIR Filter?
A Finite Impulse Response (FIR) filter is a type of digital filter whose impulse response settles to zero in a finite number of sample periods. Unlike IIR filters, FIR filters use only the current and past input samples (no feedback), making them inherently stable.
The output y[n] of a causal FIR filter of order M is computed as a weighted sum (linear convolution) of the current and past N = M + 1 input samples:
where h[k] are the filter coefficients (impulse response), x[n] is the input, and M is the filter order.
Always Stable
No feedback means the filter output is bounded for any bounded input (BIBO stable).
Linear Phase
Symmetric FIR filters have a linear phase response ā all frequency components experience the same time delay.
Flexible Design
Any frequency response can be approximated with sufficient filter order using windowing or optimization methods.
Transfer Function
In the Z-domain, the transfer function of an FIR filter is a polynomial in zā1:
All poles of H(z) lie at the origin (z = 0), confirming unconditional stability.
Discrete-Time Convolution
FIR filtering is fundamentally a linear convolution operation. Given an input signal x[n] and a filter impulse response h[n], the output y[n] is:
For a causal FIR filter of order M, this simplifies to:
This is a dot product of the reversed coefficient vector h with a sliding window of M+1 input samples.
function applyFilter(x, h):
N = length(x)
M = length(h)
y = zeros(N)
for n = 0 to N-1:
for k = 0 to M-1:
if (n - k) >= 0:
y[n] += h[k] * x[n - k]
return y
Convolution in Frequency Domain
By the Convolution Theorem, convolution in the time domain corresponds to multiplication in the frequency domain:
This means the filter shapes the spectrum of the input signal by multiplying it element-wise with the filter's frequency response H(ejĻ).
Windowing Method
The most common approach to FIR filter design is the windowing method:
Specify Ideal Response
Define the ideal frequency response Hd(ejĻ) ā a brick-wall response for LPF or HPF.
Compute Ideal Impulse Response
Take the Inverse DTFT of Hd to get hd[n], which is infinite and non-causal (sinc function).
Apply Window Function
Multiply hd[n] by a window w[n] of finite length to obtain a realizable filter.
Make Causal
Shift h[n] to make it causal: hcausal[n] = hd[n ā M/2] Ā· w[n], 0 ⤠n ⤠M.
FIR Low Pass Filter
An ideal Low Pass Filter (LPF) passes all frequencies below the cutoff Ļc with unity gain and completely blocks frequencies above Ļc.
Ideal Frequency Response
0, Ļc < |Ļ| ā¤ Ļ }
Ideal Impulse Response (IDTFT)
where sinc(x) = sin(Ļx)/(Ļx) is the normalized sinc function.
Windowed (Realizable) Impulse Response
| Parameter | Symbol | Description |
|---|---|---|
| Filter Order | M | Number of coefficients minus one (N = M + 1) |
| Cutoff Frequency | Ļc | Radians per sample (0 to Ļ); normalized: 0 to 1 |
| Center Tap | M/2 | Zero-phase reference point |
| Window | w[n] | Reduces Gibbs phenomenon at transitions |
FIR High Pass Filter
A High Pass Filter (HPF) passes frequencies above the cutoff Ļc while attenuating lower frequencies.
Spectral Inversion Method
The simplest approach derives the HPF from an LPF using spectral inversion:
where Ī“[n] is the unit impulse (Kronecker delta) and hLP[n] is the LPF impulse response.
Ideal Frequency Response
Direct Ideal Impulse Response
Design Example
HPF with Ļc = 0.5Ļ (normalized cutoff fc = 0.5), order M = 20, Hamming window:
const order = 20; // M
const wc = 0.5; // normalized cutoff (0-1 maps to 0-Ļ)
// 1. Design LPF
const hLPF = firLowPass(order, wc, 'hamming');
// 2. Spectral inversion ā HPF
const hHPF = hLPF.map((v, n) => {
const mid = Math.round(order / 2);
return (n === mid ? 1 : 0) - v;
});
Windowing Functions
Windowing mitigates the Gibbs phenomenon ā the oscillatory ringing that occurs when you abruptly truncate an infinite impulse response. Different windows trade off transition bandwidth against stopband attenuation.
- Peak Sidelobe:
ā13 dB - Min Stopband Atten.:
21 dB - Main Lobe Width:
4Ļ/N
Sharpest transition but highest sidelobe levels. Rarely used in practice.
- Peak Sidelobe:
ā43 dB - Min Stopband Atten.:
53 dB - Main Lobe Width:
8Ļ/N
Good all-around window ā wide use in audio and communications.
- Peak Sidelobe:
ā57 dB - Min Stopband Atten.:
74 dB - Main Lobe Width:
12Ļ/N
High attenuation. Used where stopband ripple must be very small.
- Peak Sidelobe:
ā31 dB - Min Stopband Atten.:
44 dB - Main Lobe Width:
8Ļ/N
Smooth tapering, commonly used in spectral analysis.
FIR vs IIR Filters
| Property | FIR Filter | IIR Filter |
|---|---|---|
| Stability | Always stable ā | May be unstable ā |
| Phase Response | Linear phase (symmetric) ā | Nonlinear phase ā |
| Computational Cost | High (more coefficients) ā | Lower (fewer coefficients) ā |
| Feedback | None (feedforward only) ā | Uses past outputs (recursion) |
| Implementation | Simple direct-form convolution | Difference equation with recursion |
| Design | Windowing method, easy ā | Bilinear transform, more complex |
Real-World Applications
Audio Processing
Bass/treble controls, equalizers, noise reduction in music production and hearing aids.
Communications
Anti-aliasing before ADC, matched filters in CDMA, channel shaping in modems.
Biomedical
ECG noise removal, EEG band-pass analysis, removing powerline interference (50/60 Hz).
Image Processing
2D FIR filters for edge detection, sharpening, blurring, and anti-aliasing in cameras.
Control Systems
Sensor data filtering in robotics, vibration analysis, and feedback control loops.
Scientific
Seismology signal analysis, radar/sonar pulse shaping, and radio astronomy.
Ready to see FIR filters in action?
Head over to the interactive simulation to experiment with all filter parameters in real time.
Open Simulation ā