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

 
 

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

Submitted by:  None
Submitted on:  Sat 05 Jul 2014 05:45:05 AM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: InvalidAssigned to: None
Originator Name: Julius SmithOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.6.4
Operating System: Mac OS

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project 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>
Project Administrator
Sat 05 Jul 2014 05:45:05 AM UTC, original submission:

To reproduce:

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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 05 Jul 2014 06:41:55 PM UTCrik5StatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1