# [Scipy-tickets] [SciPy] #1234: remez output wrong for small number of points for low order / narrowband filters

SciPy Trac scipy-tickets@scipy....
Fri Jul 16 09:02:15 CDT 2010

#1234: remez output wrong for small number of points for low order / narrowband
filters
----------------------------------+-----------------------------------------
Reporter:  tpk@…                 |       Owner:  somebody
Type:  enhancement           |      Status:  new
Priority:  normal                |   Milestone:  0.9.0
Component:  Other                 |     Version:  0.7.0
Keywords:                        |
----------------------------------+-----------------------------------------
Not even sure this is worth a ticket but it has to do with the grid
generation for narrowband filters of low order.  This filter is not
equiripple on the desired passbands:

import numpy as np

from scipy.signal import signaltools

f=np.array([0,.5,14.8,30.7/2])

h=signaltools.remez(13,np.array([0,.5,14.8,30.7/2]),[1,0],Hz=30.7,grid_density=16)

This is one such example but many others will most likely have this
problem when the filter order is small and the width of one or more bands
is small.

This was detected when comparing against MATLAB.  MATLAB uses a default
grid density of 20 and some extra grid generation logic.  In scipy, the
filter is still wrong for 20 but seems to converge for grid density of 64.
MATLAB only works for 20 by detecting that the grid has a small number of
points in the band (<11) and adding more grid points in each such band -
but that also seems like it will only work in some cases.

Perhaps a better long term solution would be to implement a final step
that adjusts the extremal points after convergence on the finite grid.  I
am not sure about the details but seem to recall Ivan Selesnick showed in
the 90's how to use remez on a finite grid to get close to the extremal
frequencies, and then do a few newton iterations to find them exactly.
But this may be sensitive to misplacement of the extremals so it may not
be as simple as that - that is, there may be some study / experimentation
required.  Also, the matrix sizes might be a bit large...

Given that it is possible to obtain a correct filter in scipy with a
larger grid density, I am marking this ticket as an enhancement rather
than a bug (although one could argue that it is a bug).

--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1234>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.