0
0
RosConceptBeginner · 3 min read

What is FIR Filter: Definition, Example, and Uses

A FIR filter (Finite Impulse Response filter) is a type of digital filter that processes signals by applying a fixed set of coefficients to a limited number of past input values. It produces an output that depends only on current and past inputs, making it stable and easy to design.
⚙️

How It Works

A FIR filter works by taking a small window of recent input signal values and multiplying each by a fixed weight called a coefficient. Then, it adds all these weighted values together to produce the current output. Imagine it like making a smoothie where each fruit (input value) is added in a certain amount (coefficient) to get the final taste (output).

Because it only uses a limited number of past inputs and never feeds back its output, the FIR filter is always stable and predictable. The shape of the filter’s response depends on the coefficients, which you can design to remove noise, smooth data, or extract certain frequencies from a signal.

💻

Example

This example shows a simple FIR filter that smooths a noisy signal by averaging the last three input values.

python
import numpy as np
import matplotlib.pyplot as plt

# Sample noisy signal
np.random.seed(0)
signal = np.sin(np.linspace(0, 2 * np.pi, 50)) + np.random.normal(0, 0.3, 50)

# FIR filter coefficients for simple moving average of 3 points
coefficients = np.array([1/3, 1/3, 1/3])

# Apply FIR filter using convolution
filtered_signal = np.convolve(signal, coefficients, mode='valid')

# Plot original and filtered signals
plt.plot(signal, label='Original Signal')
plt.plot(range(2, 50), filtered_signal, label='Filtered Signal (FIR)')
plt.legend()
plt.title('FIR Filter Example: Moving Average')
plt.show()
🎯

When to Use

Use FIR filters when you need a stable and simple digital filter that does not change over time. They are great for smoothing noisy data, removing unwanted frequencies, or shaping signals in audio and communication systems. Because FIR filters have no feedback, they are easier to design and less likely to cause errors in sensitive applications.

For example, in audio processing, FIR filters can remove background noise without distorting the sound. In sensor data, they help smooth out random fluctuations to reveal the true signal.

Key Points

  • FIR filters use a fixed number of past input values and coefficients to produce output.
  • They are always stable because they do not use feedback.
  • Easy to design and implement for many signal processing tasks.
  • Commonly used for smoothing, noise reduction, and frequency filtering.

Key Takeaways

A FIR filter processes signals using fixed coefficients on past inputs without feedback.
It is stable and predictable, making it ideal for smoothing and noise reduction.
FIR filters are simple to design and widely used in audio and sensor signal processing.
They work by averaging or weighting recent input values to shape the output signal.