octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should interp1.m function allow jumps in X-values?


From: Juan Pablo Carbajal
Subject: Re: Should interp1.m function allow jumps in X-values?
Date: Tue, 21 Aug 2012 14:47:12 +0200

On Tue, Aug 21, 2012 at 2:45 PM, Juan Pablo Carbajal
<address@hidden> wrote:
> On Tue, Aug 21, 2012 at 2:22 PM, vivek dogra <address@hidden> wrote:
>>
>>
>> On Tue, Aug 21, 2012 at 5:51 PM, Martin Helm <address@hidden> wrote:
>>>
>>> Am 21.08.2012 14:15, schrieb vivek dogra:
>>> >
>>> >
>>> > By neither increasing nor decreasing, i meant if it is unsorted.
>>> > example:
>>> >
>>> > X = [ 2 1 2 3];
>>> > Y = [ 2 1 3 4];
>>> >
>>> This was already ruled out by Ben's answer that in such a case the
>>> vector will be sorted! So the only case which was left is the constant
>>> one.
>>
>>
>> So it means whenever X is unsorted, interp1 will always give the
>> "discontinuous interpolant" corresponding to increasing values of X. It
>> means it is hard coded in the function that it will always sort X in
>> increasing order. So, it is not symmetric. Why interp1 is favoring
>> right-continuous?
>>
>> Now looking from the practical point of view let's say (because of some
>> error) we have following data points:
>> X = [ 1 2 2 3];
>> Y = [ 1 2 10 4];
>>
>> In this case because X is increasing, interp1 will consider value of 2 as
>> 10.
>>
>> which is of course incorrect.
>> In this case it will be better for the user to do some pre-processing (as in
>> whether to take the max., min., or the mean of 2 identical values)
>>
>
> The interpolation problem is defined as
>
> m(x_i) = y_i
>
> Where m is the interpolant and the pairs (x_i,y_i) is the given data.
> Clearly, data with (x_i,y) = (x_i, z)  with i different from j does
> not accept and interpolant. When for a given value of x you have
> multiple values of y, you are in the approximation or regression
> realm.
> If you want to solve these problem you can use regress, check regress
> and regress_gp functions in the statistics-1.1.3 Forge package.
>
> A homebrew way to go is to take the mean value of the repeated data
> and interpolate that, e.g. (x_i, (y+z)/2). This is similar to
> calculate the two interpolant and then take the pointwise mean.
>
> Cheers
>
> --
> M. Sc. Juan Pablo Carbajal
> -----
> PhD Student
> University of Zürich
> http://ailab.ifi.uzh.ch/carbajal/

addendum: Repeated x values with different values of y do not accept a
continuous interpolant, which is what interp1 is calculating.


-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]