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: vivek dogra
Subject: Re: Should interp1.m function allow jumps in X-values?
Date: Tue, 21 Aug 2012 18:27:10 +0530

On Tue, Aug 21, 2012 at 6:15 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/
I have gone through the code thoroughly. Yes sorting is definitely required, if we are dealing with X having distinct values it is perfectly alright. Although if it has identical values then it is always favoring increasing order (why, it is not symmetric). Plus i am not looking at the Manual because very basic theoretical and physical concept is violated here!  If i am a researcher who wants to interpolate i don't want Octave to decide for me which values are taken for interpolation if there are identical values, the decision solely depends on the researcher!

reply via email to

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