bugGNU Octave - Bugs: bug #42686, interp1 returns NAs in simple...

 
 

bug #42686: interp1 returns NAs in simple cases where 0 expected

Submitter:  None
Submitted:  Sat 05 Jul 2014 05:45:05 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Julius Smith Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.6.4
Operating System:  * Mac OS Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 05 Jul 2014 07:38:36 PM UTC, comment #3: 

Octave tries pretty hard to stay compatible with Matlab and Matlab returns NaNs for the default case of linear interpolation.  The idea is that one shouldn't trust interpolated data outside it's region of validity.  Throwing NAs or NANs indicates that fact and does pollute downstream calculations purposefully.  The user can override this, but this ensures that a human makes a conscious choice about how to interpret the data.  For example, instead of 2.1 the requested interpolation point could have been 1e6.  With the "extrap" option set Octave will return a value, but I wouldn't trust it as it is so far from the original region.

Rik <rik5>
Group administrator
Sat 05 Jul 2014 07:21:03 PM UTC, comment #2: 

Apologies for not studying the help to learn that this behavior is on purpose.  I didn't think to do that because the behavior was so obviously not what one would expect.  I therefore submit that 'extrap' should be the default behavior.  Octave users typically know what polynomial interpolation is, and so they would naturally expect polynomial extrapolation outside the range of given points.  Getting NA is a very bad default, because NAs tend to cause destruction much later as they propagate, leading to a time-consuming search for the first creation of NA in the results.

Anonymous
Sat 05 Jul 2014 06:41:55 PM UTC, comment #1: 

This is the expected behavior.  Try 'help interp1' to get the documentation on the function.  The value 2.1 is outside the range of the original data points so there is no data for Octave to interpolate.  However, you can specify how Octave will treat data which is outside the original data.  Look at the 'extrap' option.

Rik <rik5>
Group administrator
Sat 05 Jul 2014 05:45:05 AM UTC, original submission:  

To reproduce:


> interp1([1 2],[0 0],[1.1 2.1])
ans =

     0    NA
> interp1([1 2],[0 0],[1.1 1.9])
ans =

   0   0


This example was simplified from a much larger example for which Y started out with zeros and then became nonzero.  Perhaps something singular happens when the leading given samples are zero?  Note that it seems to be well behaved when the interpolated indices are interior to the given indices.

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 rik5 (Posted a comment)
  • -email is unavailable- added by None (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-07-05 rik5 StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code