bugGNU Octave - Bugs: bug #57399, "griddata" result...

 
 

bug #57399: "griddata" result different from Matlab

Submitter:  Hosam Mukhairez <hmukhairez>
Submitted:  Thu 12 Dec 2019 01:55:53 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 5.1.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 19 Feb 2021 05:47:33 AM UTC, comment #24: 

I believe Hg200's analysis in comment #23 is correct.

Marking bug as fixed and closing report.

Rik <rik5>
Group administrator
Thu 31 Dec 2020 10:56:07 PM UTC, comment #23: 

I have had a look at this again. The OP presented a data set where griddata interpolates differently in Matlab than it does in Octave. The dataset being interpolated is a function with superimposed noise. griddata does its interpolation based on a Delaunay triangulation. A Delaunay triangulation is not "unique", i.e. there can be different triangulations for a given problem and so the triangulation between Octave and Matlab can be different too unless not 100% the same code is used. Now, if a curve is not sufficiently smooth, i.e. the grid points are not dense enough, then the interpolation to a different Delaunay triangulation is different too.

Then there was bug #50494. In the end, Rik changed the Delaunay flags to fix bug #50494. I have tested the problem again on the current development branch and get the same results as already posted in comment #19. The left image shows the region of interest as already examined in comment #13, and the right image shows the difference between the Matlab interpolation that Markus attached to this report and the interpolation that griddata creates on Octave. I attached the script again because I didn't do that last time.

In the end there is still a difference between Octave and Matlab, because otherwise the right image would show a flat plane. However, the difference is the same magnitude as the "superimposed noise". Also all the dataset points "touch" the interpolation curve (all red dots in the right picture are at z=0). IMO, the griddata result in Octave is just as "bad" or "good" as the one from Matlab. If you want more "equality", then the sample points have to be chosen tighter.

Therefore I vote to close this report.


(file #50594)

Hg200 <hg200>
Mon 27 Jul 2020 01:14:01 PM UTC, comment #22: 

OK to close this report as fixed or should the status be changed to something other than ready for test?

John W. Eaton <jwe>
Group administrator
Tue 10 Mar 2020 08:01:47 PM UTC, comment #21: 

the results from comment #19 indicate that there may still be differences compared to matlab. that bug made changes to c files as well as m files, so evaluating the changes would require compiling from source, as I don't think that bugfix made it into v5.2

Nicholas Jankowski <nrjank>
Group Member
Wed 18 Dec 2019 12:46:41 PM UTC, comment #20: 

thank you all very being interested in this issue ..
is the problem solved? ... if so ... how can i test the solved function in my java code ?

Best regards

Hosam Mukhairez <hmukhairez>
Tue 17 Dec 2019 10:04:29 PM UTC, comment #19: 

I have merged the patch from bug #50494


{"Qt", "Qbb", "Qc"}


The left side of the attached picture shows the section already mentioned below. The difference is hard to see, but there is one. The right side of the picture shows the difference between the interpolation of matlab and octave (for the data set "b"). If there were no differences between matlab and octave, the difference would be zero.



Hg200 <hg200>
Mon 16 Dec 2019 10:54:01 PM UTC, comment #18: 

This is very likely related to the loss of precision in the Qhull library caused by the different options passed by Matlab and Octave by griddata.  There was a separate bug report #50494 which I just resolved whichis likely to resolve this report as well.

Marking as "Ready for Test"

Rik <rik5>
Group administrator
Sat 14 Dec 2019 11:12:15 PM UTC, comment #17: 

'Qbb' transforms the section shown in comment #13 into a third variant. I also cannot say whether one of the different interpolations is superior over the other. The injected error has a similar magnitude as the additive noise in the dataset. It is important to me that the mesh runs through the data points (red dots do touch the mesh) and that the interpolation function is linear.

Btw: A


trisurf (tri, x, y, z)


call in griddata.m reveals that we see the delaunay triangulation in the plots in deed.

Hg200 <hg200>
Fri 13 Dec 2019 07:55:38 PM UTC, comment #16: 

According to some old archived documentation, the default options for Delaunay used to be {'Qt','Qbb','Qc'}.

In Octave, they are {'Qt','Qbb','Qc', 'Qz'}.

One could try passing the smaller option set to delaunay() and see if that made a difference.

Otherwise, it may be a difference in the post-processing in griddata done for the "linear" method.

Rik <rik5>
Group administrator
Fri 13 Dec 2019 07:50:58 PM UTC, comment #15: 

Good illustration of the differences.
It looks like the diagonals in Matlab's triangulation result are all oriented in the same direction. In Octave, the diagonals seem to be oriented more randomly. Is there a reason for this?

Other than that: I don't know why one of the triangulation results should be more valid than the other. But I'm not an expert.

Markus Mützel <mmuetzel>
Group administrator
Fri 13 Dec 2019 07:50:19 PM UTC, comment #14: 

We don't necessarily expect the Delaunay triangulation to be the same, if that is where the difference is coming from.  There may be differences in the options passed to the QHull library between Octave and Matlab.  Matlab used to allow you to set these options, and we chose the same ones at the time.  Currently, they do not say what options they are using so it may have changed.

Rik <rik5>
Group administrator
Fri 13 Dec 2019 06:00:19 PM UTC, comment #13: 

looks to me like the triangulation is different (see attachment).

do we expect equal triangulation?


file #48058)

Hg200 <hg200>
Fri 13 Dec 2019 03:56:11 PM UTC, comment #12: 

I can confirm that the results with Matlab R2016a differs from Octave 5.1.

I used the attached script to write the resulting matrices to files in Matlab and Octave (also attached).
Looking at e.g. the bi matrices, the deviations seem to be largest between the original grid (e.g. at xi = 7.5 and yi = 10.5).

(file #48051, file #48052, file #48053)

Markus Mützel <mmuetzel>
Group administrator
Fri 13 Dec 2019 03:28:17 PM UTC, comment #11: 

excuse me ... but what do you mean ? i didn't understand you ?

Hosam Mukhairez <hmukhairez>
Fri 13 Dec 2019 03:26:49 PM UTC, comment #10: 

File named 3 is there now.

Doug Stewart <dastew>
Fri 13 Dec 2019 03:00:18 PM UTC, comment #9: 

i added the file now ... you can check please

Hosam Mukhairez <hmukhairez>
Fri 13 Dec 2019 02:35:43 PM UTC, comment #8: 

AFAICT, uploading to savannah is fixed again.
Could you please provide the file '3' in your example?

Markus Mützel <mmuetzel>
Group administrator
Fri 13 Dec 2019 07:08:50 AM UTC, comment #7: 

yes Mr. Markus Mützel
I downloaded the version "octave-5.1.0-w64-installer"
and executed the script and gave me same results as the old version

these results from the new and old version are defers when executing the same script using Matlab

my script is
=================================
addpath('C:\Users\Hosam\Desktop\');

data4 = dlmread('3', ';');

x = data4(:,1);
y = data4(:,2);
v = data4(:,3);
z = data4(:,4);
k = data4(:,5);
b = data4(:,6);
o = data4(:,7);

x1=min(x):0.1:max(x);
y1=min(y):0.1:max(y);
z1=min(z):0.1:max(z);


[xi,yi] = meshgrid(x1,y1);


zi = griddata(x,y,z,xi,yi,'linear');
vi = griddata(x,y,v,xi,yi,'linear');
ki = griddata(x,y,k,xi,yi,'linear');
bi = griddata(x,y,b,xi,yi,'linear');
oi = griddata(x,y,o,xi,yi,'linear');

V = reshape(vi,numel(vi),1)
save('-ascii',strcat('C:\Users\Hosam\Desktop','/V.txt'),'V');

X = reshape(xi,numel(xi),1)
save('-ascii',strcat('C:\Users\Hosam\Desktop','/X.txt'),'X');

Y = reshape(yi,numel(yi),1)
save('-ascii',strcat('C:\Users\Hosam\Desktop','/Y.txt'),'Y');

Z = reshape(zi,numel(zi),1)
save('-ascii',strcat('C:\Users\Hosam\Desktop','/Z.txt'),'Z');

K = reshape(ki,numel(ki),1)
save('-ascii',strcat('C:\Users\Hosam\Desktop','/K.txt'),'K');

B = reshape(bi,numel(bi),1)
save('-ascii',strcat('C:\Users\Hosam\Desktop','/B.txt'),'B');

O = reshape(oi,numel(oi),1)
save('-ascii',strcat('C:\Users\Hosam\Desktop','/O.txt'),'O');
=================================

Hosam Mukhairez <hmukhairez>
Fri 13 Dec 2019 06:40:05 AM UTC, comment #6: 

Thanks for trying.
Savannah has issues recently. Please, write to the help mailing list -email is unavailable- attaching your files and referencing this report number.

Markus Mützel <mmuetzel>
Group administrator
Fri 13 Dec 2019 06:38:29 AM UTC, comment #5: 

Sorry for the inconvenience, Savannah has at the moment a problem with uploading files, see https://savannah.nongnu.org/support/?110158.  Please try again tomorrow or later.

Kai Torben Ohlhus <siko1056>
Group Member
Fri 13 Dec 2019 06:35:58 AM UTC, comment #4: 

I tried now to upload the files .. but the website says the following error
The upload directory '/var/lib/savane//trackers_attachments' is not writable. The upload directory '/var/lib/savane//trackers_attachments' is not writable.

Hosam Mukhairez <hmukhairez>
Fri 13 Dec 2019 06:34:21 AM UTC, comment #3: 

I uploaded the files yesterday but a server error says that the file were not uploaded .. I'll try upload them again and I'll try the latest version of octave to check the results

Hosam Mukhairez <hmukhairez>
Thu 12 Dec 2019 04:59:44 PM UTC, comment #2: 

Also, the listed version is Octave 4.2.1 which is out-of-date and no longer supported.  At the very least, try running your script on a modern version of Octave and see if the results are different.

Rik <rik5>
Group administrator
Thu 12 Dec 2019 03:46:01 PM UTC, comment #1: 

There is no script attached to this report.

Markus Mützel <mmuetzel>
Group administrator
Thu 12 Dec 2019 01:55:53 PM UTC, original submission:  

I've ran a script on Octave ..
this script includes "griddata" function

my script is attached with this report

the output of this script defers when i run the same script on Matlab

is the functionality of "griddata" function defers between Octave and Matlab ?

Hosam Mukhairez <hmukhairez>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #50594:  comment19_tests.tar.gz added by hg200 (142KiB - application/gzip)
file #48079:  patch25f914321e7b.png added by hg200 (181KiB - image/png)
file #48057:  comparison.png added by hg200 (247KiB - image/png)
file #48058:  test_interpolation.m added by hg200 (6KiB - text/x-objcsrc)
file #48051:  bug57399.m added by mmuetzel (1KiB - text/plain)
file #48052:  bug57399_Matlab.zip added by mmuetzel (397KiB - application/x-zip-compressed)
file #48053:  bug57399_Octave.zip added by mmuetzel (394KiB - application/x-zip-compressed)
file #48050:  3 added by hmukhairez (18KiB - application/octet-stream)

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by hg200 (Updated the item)
  • -email is unavailable- added by dastew (Posted a comment)
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by hmukhairez (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 18 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-02-19 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2020-12-31 hg200 Attached File- Added comment19_tests.tar.gz, #50594
    2019-12-17 hg200 Attached File- Added patch25f914321e7b.png, #48079
    2019-12-16 rik5 Dependencies- Depends on bugs #50494
    2019-12-16 rik5 StatusConfirmed Ready For Test
    2019-12-13 hg200 Attached File- Added comparison.png, #48057
        Attached File- Added test_interpolation.m, #48058
    2019-12-13 mmuetzel Attached File- Added bug57399.m, #48051
        Attached File- Added bug57399_Matlab.zip, #48052
        Attached File- Added bug57399_Octave.zip, #48053
        Item GroupNone Matlab Compatibility
        StatusNeed Info Confirmed
        Release4.2.1 5.1.0
        Operating SystemMicrosoft Windows Any
        SummaryGriddata Result "griddata" result different from Matlab
    2019-12-13 hmukhairez Attached File- Added 3, #48050
    2019-12-12 rik5 StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code