bugGNU Octave - Bugs: bug #56851, [octave forge] (signal) butter...

 
 

bug #56851: [octave forge] (signal) butter returns incorrect value

Submitter:  None
Submitted:  Mon 02 Sep 2019 06:08:21 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Works For Me Assigned to:  None
Originator Name:  hjborsje Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 5.1.0
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 30 Sep 2019 10:52:23 PM UTC, comment #11: 

No further responses, closing as working fine.

If there are more comments or suggestions, do feel free to comment even on a closed bug report.

Mike Miller <mtmiller>
Group Member
Tue 10 Sep 2019 03:38:20 PM UTC, comment #10: 

Ok, it looks to me like filtfilt is returning an output regardless of the warning message. If I disable the warning, there doesn't seem to be any problem here. The warning is removed permanently in Octave version 6.

Is the presence of the divide-by-zero warning the only problem you are reporting here? If so, that's already fixed in Octave 6, and easy to silence in any previous version of Octave.

Mike Miller <mtmiller>
Group Member
Tue 10 Sep 2019 08:22:00 AM UTC, comment #9: 

Sorry for not being clear in this matter.  I use the function filtfilt.  Line 66 uses sum(b)/sum(a).  This is where the division by zero occurs.

Henk B

Henk Borsje <hjborsje>
Mon 09 Sep 2019 08:49:06 PM UTC, comment #8: 

We can show that it's not an error for the butter function to return filter coefficients that aren't practically useful when the filter spec is unreasonable. IOW, garbage in == garbage out.

For compatibility with Matlab, the butter function should not enforce some kind of constraints on the input or output and report an error, it should just return what it can compute.

Can you show specifically what gives you a division by zero? Not the 'filter' function and not the 'freqz' function. Maybe some other function can report an improved error message in this case?

Mike Miller <mtmiller>
Group Member
Thu 05 Sep 2019 06:53:05 AM UTC, comment #7: 

You can close it as a bug, but is there room for improvement?  It currently results in division by zero.

Henk Borsje <hjborsje>
Wed 04 Sep 2019 07:12:49 PM UTC, comment #6: 


> Apparently butter(5,1/28800) is not a feasible filter


Does this mean you think this bug report should be closed as invalid?

Mike Miller <mtmiller>
Group Member
Wed 04 Sep 2019 05:45:00 PM UTC, comment #5: 

Apparently butter(5,1/28800) is not a feasible filter, given the reported differences in returned coefficients.  My expectation is based on the MATLAB idfilt function in the system identification toolbox.
idfilt(z,[0 1/28800],'FilterOrder',5) does seem to work correctly. According to the documentation idfilt uses a Butterworth filter.

idfilt does not seem to exist in Octave

Henk Borsje <hjborsje>
Tue 03 Sep 2019 04:49:35 PM UTC, comment #4: 

Different versions of Matlab return different results from what is suggested in comment #0. With Matlab's online version R2019a, sum(a) returns -eps and sum(b) returns 0.

Mike Miller <mtmiller>
Group Member
Tue 03 Sep 2019 07:12:32 AM UTC, comment #3: 

It sure does look like a round-off error, but one with grave consequences.  This filter spec is not unreasonable.  Changing the spec to e.g. butter(4,1/28800) works correctly, as well as butter (5,1/28801).  The resulting sum(a) = 0 causes a division by 0 when one tries to use the filter.   MATLAB handles this case correctly, so it sounds like a bug to me.

Henk Borsje <hjborsje>
Mon 02 Sep 2019 09:57:24 PM UTC, comment #2: 

I think you are seeing roundoff errors from floating point arithmetic.

Doug Stewart <dastew>
Mon 02 Sep 2019 06:38:05 PM UTC, comment #1: 

are you wanting an analogue or digital filter?

Doug Stewart <dastew>
Mon 02 Sep 2019 06:08:21 PM UTC, original submission:  


>> [b,a] = butter (5,1/28800)

b =

 Columns 1 through 4:

   4.825699732353868e-22   2.412849866176934e-21   4.825699732353867e-21   4.825699732353867e-21

 Columns 5 and 6:

   2.412849866176934e-21   4.825699732353868e-22

a =

 Columns 1 through 4:

   1.000000000000000e+00  -4.999646999743641e+00   9.998588061278351e+00  -9.997882185366413e+00

 Columns 5 and 6:

   4.998588185872336e+00  -9.996470620406335e-01>>

>> [sum(a) sum(b)]

ans =

   0.000000000000000e+00   1.544223914353238e-20


MATLAB returns the value 5.5511e-16 for sum(a) and 8.88178e-16 for sum(b)

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by hjborsje (Posted a comment)
  • -email is unavailable- added by dastew (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-09-30 mtmiller StatusNeed Info Works For Me
        Open/ClosedOpen Closed
    2019-09-09 mtmiller StatusNone Need Info
    2019-09-03 rik5 Carbon-CopyRemoved 72865 -
    2019-09-03 mtmiller Summarybutter returns incorrect value [octave forge] (signal) butter returns incorrect value
    2019-09-03 rik5 CategoryOctave Function Octave Package

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code