# Scipy visualize Linear filter using numerator coefficients

Python scipy signal package has a function freqs to get the frequency response of a linear filter from [b, a] numerator and denominator. So, I should be able to get the response using the code below

w, h = scipy.signal.freqs(numerator, denominator)

I created an FIR filter (equiripple) using matlab as follows and got the corresponding numerator values into python

As I figured out from this question, I should set the denominator to either [1, 0, 0, ...] or just [1]

Here's the code I use to plot the frequency response (I want to reproduce the plot Matlab tool showed me so I'm not using a log x axis)

from scipy import signal
import numpy as np
import matplotlib.pyplot as plt

w, h = signal.freqs(numerator, denominator, worN=np.arange(0, 4001))
plt.plot(w, 20 * np.log10(abs(h)))
plt.xlabel('Frequency')
plt.ylabel('Amplitude response [dB]')
plt.show()

When I use denominator as [1, 0, 0, ...], I get this output plot

denominator = np.zeros(len(numerator))
denominator[0] = 1

When I use denominator as [1], I get this

denominator = [1]

Neither of these are the expected plot. But when I use the same numerator with scipy.signal.lfilter, I get the expected filtered output. Both [1, 0, 0, ...] and [1] denominator works similarly in that case.

x_filtered = signal.lfilter(numerator, denominator, x)  # x is my input signal

What am I missing here?

Here's the numerator coefficients I got from Matlab filterDesigner tool

numerator = [0.0004505121978623484, 0.0015391270577797295, 0.0034849738530219137, 0.0059935571891852986, 0.008153435576056406, 0.00859295274071084, 0.00606548279898037, 0.0002846755213858822, -0.00742297904630505, -0.014153857203798368, -0.016427408828624798, -0.011924076853454632, -0.0011931648752793917, 0.011684815603418677, 0.020213206095187067, 0.018298423359451726, 0.003718245377587605, -0.019451127400893112, -0.04099016948947245, -0.04779531970776775, -0.029274426761207544, 0.01733488350917493, 0.08424518003037892, 0.1546060172782279, 0.20800438955526646, 0.2279136247956023, 0.20800438955526646, 0.1546060172782279, 0.08424518003037892, 0.01733488350917493, -0.029274426761207544, -0.04779531970776775, -0.04099016948947245, -0.019451127400893112, 0.003718245377587605, 0.018298423359451726, 0.020213206095187067, 0.011684815603418677, -0.0011931648752793917, -0.011924076853454632, -0.016427408828624798, -0.014153857203798368, -0.00742297904630505, 0.0002846755213858822, 0.00606548279898037, 0.00859295274071084, 0.008153435576056406, 0.0059935571891852986, 0.0034849738530219137, 0.0015391270577797295, 0.0004505121978623484]