After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 680510 - interpolation function should work with decreasing abscissas
interpolation function should work with decreasing abscissas
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: Analytics
git master
Other Linux
: Normal enhancement
: ---
Assigned To: Morten Welinder
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2012-07-24 09:24 UTC by Frédéric Parrenin
Modified: 2013-03-21 13:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
.gnumeric file to reproduce the problem (1.87 KB, application/x-gnumeric)
2012-07-24 09:24 UTC, Frédéric Parrenin
  Details
proposed patch (2.67 KB, patch)
2012-07-27 09:09 UTC, Andreas J. Guelzow
none Details | Review

Description Frédéric Parrenin 2012-07-24 09:24:02 UTC
- open the attached .gnumeric file
- cell D1 displays #Value!
- switch cells A1 and A2
- cell D1 now displays 1
Comment 1 Frédéric Parrenin 2012-07-24 09:24:32 UTC
Created attachment 219562 [details]
.gnumeric file to reproduce the problem
Comment 2 Andreas J. Guelzow 2012-07-27 09:09:58 UTC
Created attachment 219727 [details] [review]
proposed patch
Comment 3 Andreas J. Guelzow 2012-07-27 17:50:31 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
Comment 4 Frédéric Parrenin 2012-07-27 20:40:08 UTC
The patch does actually more than just decreasing abscissas.
It does random abscissas by re-ordering them.
Comment 5 Andreas J. Guelzow 2012-07-27 20:46:38 UTC
I know. That was intended.
Comment 6 Frédéric Parrenin 2012-07-31 11:28:14 UTC
There are certainly some value to propose an automatic re-ordering but it might be dangerous too.
In the case when there are identical abscissas, gnumeric now report an error but it would be more helpful to make an average of the ordinates with the same abscissas. (in data analysis, it is quite common to have duplicate measurements and in this case the common procedure is to take the average)
Other remarks:
- gnumeric reports an error when one of the data (abscissa or ordinate) is an error (#NUM!, #DIV/0!, #VALUE!). It would be more helpful to skip these data, as is done for the XY plots.
- Linear Interpolation of (1;2;0) (2;3;2) in 3 gives 3.5. It should give 4. (the re-ordering affects the result)
Comment 7 Morten Welinder 2012-07-31 13:39:05 UTC
If you have multiple data points with the same "x" value, you are using
the wrong tool.  Interpolation is a connect-data-with-some-curve game.
What you describe calls for best-fit-within-function-class.  That kind
of thing is available, for example via functions like LINEST.
Comment 8 Morten Welinder 2012-07-31 13:53:51 UTC
> - Linear Interpolation of (1;2;0) (2;3;2) in 3 gives 3.5. It should give 4.
> (the re-ordering affects the result)

Why?  to get 4, it would have to be (2;3;1).
Comment 9 Andreas J. Guelzow 2012-07-31 14:30:51 UTC
Morten, 
=interpolation(array(1,2,0),array(2,3,2),3)  and
=interpolation(array(0,1,2),array(2,2,3),3)
should be the same, but aren't, they are 3.5 and 4 respectively.

since for values outside the range we are extrapolating based on the last 2 values (on that side), 4 would be correct.
Comment 10 Andreas J. Guelzow 2012-07-31 15:49:11 UTC
The 3.5 vs 4 was a stupid coding error on my part.

This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
Comment 11 Frédéric Parrenin 2012-08-01 09:47:52 UTC
Hi Andreas,
So how would you proceed if you had a serie (X_i,Y_i) and wanted to eliminate the duplicate X_i by taking the average of the corresponding Y_i?
Comment 12 Andreas J. Guelzow 2012-08-01 16:33:23 UTC
Frederic, First of all I would ask myself why I have duplicate X_i. In the case of duplicate X_i, I either don't have a function I could interpolate or my Y_i are error-laden and interpolation may be inappropriate, but a statistical model may be much more appropriate.
Comment 13 Frédéric Parrenin 2012-08-02 10:09:06 UTC
OK, thank you for your fix BTW.
Comment 14 Frédéric Parrenin 2012-08-07 09:55:29 UTC
Sorry to come back here, it still seems valuable to have the interpolation function taking the average of the Y_i for duplicate X_i. I will try to propose a patch.
Comment 15 Frédéric Parrenin 2013-03-21 13:39:05 UTC
After more thoughts and uses, I find it too dangerous to re-order the series before doing the interpolation.
It prevents you from finding errors in your code.
I would advocate to do the interpolation only for strictly increasing or strictly decreasing abscissas.