bugGNU Octave - Bugs: bug #56636, Octave's interp1 does not have the...

 
 

bug #56636: Octave's interp1 does not have the same rules for when to extrapolate as Matlab.

Submitter:  Richard <crobar>
Submitted:  Mon 15 Jul 2019 10:10:00 PM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  2 Item Group:  WTF, Matlab?!?
Status:  Confirmed Assigned to:  None
Originator Name:  Richard Crozier Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 16 Jul 2019 09:21:30 PM UTC, comment #2: 

Is there a way that Octave could follow the Matlab defaults if octave is launched with the '--traditional' option?

Richard <crobar>
Mon 15 Jul 2019 10:48:28 PM UTC, comment #1: 

Confirmed, and I agree that it is terribly confusing to make the default value of "extrap" depend on the interpolation method used.  If the user want's extrapolation, then just say so by providing the option.  Otherwise, don't provide extrapolation.  I changed the severity and the priority to low values.  It is an incompatibility, but I don't want to chase after Matlab in this regard.

Rik <rik5>
Group administrator
Mon 15 Jul 2019 10:10:00 PM UTC, original submission:  


This has sort of been reported in bug #42686, but that bug is closed.

The rules for when interp1 performs extrapolation, rather than returning a Nan outside the domain differ for Octave and Matlab.

In Matlab for example:


x = linspace (0, 10, 100);
y = x .* 10;

yq = interp1 (x, y, 11, 'spline')

yq =

   110.0000e+000


In Octave this returns nan.

The Octave docs state "If extrap is the string "extrap", then extrapolate values beyond the endpoints using the current method. If extrap is a number, then replace values beyond the endpoints with that number. When unspecified, extrap defaults to NA. "

This differs for Matlab, where for the 'pchip', 'spline', or 'makima' interpolation methods, then the default behaviour is 'extrap', but otherwise the behaviour is the same as Octave where the default is nan, unless extrap is specified explicitly.

Personally I prefer the Octave way and think silently extrapolating without warning the user, or the user asking for it, and having different defaults depending on the extrapolation method is a bit mad, but it is definitely an incompatibility.


Richard <crobar>

 

(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 rik5 (Posted a comment)
  • -email is unavailable- added by crobar (Submitted the item)
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-07-15 rik5 Severity3 - Normal 2 - Minor
        Priority5 - Normal 2
        StatusNone Confirmed
        Release5.1.0 dev

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code