[SciPy-Dev] scipy.signal.butter returns complex coefficients

Charles R Harris charlesr.harris at gmail.com
Thu Feb 21 16:11:05 EST 2013


On Thu, Feb 21, 2013 at 10:03 AM, Pierre Haessig
<pierre.haessig at crans.org>wrote:

>  Hi Chuck,
>
> Le 21/02/2013 17:53, Charles R Harris a écrit :
>
>  Now, it may be possible to write signal.buttap in a bit more complex
>> fashion to generate true complex conjugate roots but I'm not sure it's a
>> good to rely on np.poly to make some "smart conjugate detection". In the
>> new polynomial package I'm not sure this is even implemented (
>> https://github.com/numpy/numpy/blob/master/numpy/polynomial/polynomial.py#L127).
>> From my unexerced eye, the code of
>> numpy.polynomial.polynomial.polyfromroots and numpy.poly looks very
>> different
>>
>
> The multiplications in numpy/polynomial/polynomial are done as a sort of
> binary tree, multiplying successively higher degree polynomials together
> while trying to keep the roots in each widely separated so as to minimize
> numerical error, but it make no attempt to detect conjugate roots. It
> probably needs an `asreal` attribute so the user, who knows more about the
> problem than the computer, can specify the type of the result.
>
> I fully agree with this "explicit better than implicit" approach.
> (and thanks for the explanation of the iterative construction of the
> polynomial)
>
> Do you think `asreal` it would be a useful addition to polyfromroots or is
> it better to just call np.real in signal.iirfilter ?
>

I think it, or something with a similar name, should be added, but it won't
be available until the next release at a minimum. So, taking the real part
of the coefficients is probably the way to go. I'm trying to recall which
release the polynomial functions went in... looks like 1.5, so that should
be OK for scipy.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20130221/54278439/attachment.html>


More information about the SciPy-Dev mailing list