# Remez function equivalency between Matlab and Scipy

I've read the similar question Find the equivalent of this python remez specs in C++ remez or Matlab firpm, which describes a different problem.

In Matlab, I have following remez and firpm function calls:

remez(10,[0 .1 1-.1 1],[1 1 0 0])
firpm(10,[0 .1 1-.1 1],[1 1 0 0])


and in Scipy, I can achieve the same filter by calling:

signal.remez(11, bands=[0, .1, 1.0 - .1, 1], desired=[1, 0], fs=2)


Both 3 function calls returns me the same coefficients:

ans =

0.0066   -0.0000   -0.0510    0.0000    0.2944    0.5000    0.2944    0.0000   -0.0510   -0.0000    0.0066


The problem is: when I attempt to sharpen the corner frequency from the half pass filter, by substituting the Δf = .1 to Δf = .01, the output from Scipy is an array of nan.

remez(10,[0 .01 1-.01 1],[1 1 0 0])
firpm(10,[0 .01 1-.01 1],[1 1 0 0])


both Matlab calls returns me the same filter coefficients:

ans =

0.0059   -0.0000   -0.0488    0.0000    0.2930    0.5000    0.2930    0.0000   -0.0488   -0.0000    0.0059


By attempting to get the same filter from Scipy,

signal.remez(11, bands=[0, .01, 1.0 - .01, 1], desired=[1, 0], fs=2)


the result is:

array([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan])


I don't know exactly if there's something wrong with the arguments or maybe a precision problem in the Python call. Any help is appreciated!

The solution is to use the grid_density parameter, which is the dense grid used in the Remez exchange algorithm. The default is 16 and for 11 taps results in a dense grid of 12 x 16 which is too small for such a wide transition range. The following will produce useful results:
sig.remez(11, bands=[0, .01, .99, 1], desired=[1, 0], grid_density=61, fs=2)