TGraph2D interpolation problem

Hi,

This might be related to:

I would like to use a TGraph2D to smooth a curve f(a,b).
After filling the graph, TGraph2D->Interpolate(a,b)
returns 0 in many cases. This includes exact input points
and exact input points plus a small (+0.001) offset.
Draw does produce a reasonable smooth curve.
I tested this with several versions of 5.34 including 5.34/18 on lxplus.
To reproduce, please see attached file.

Double_t pt = 50 + 0.001;
Double_t eta = 1. + 0.01*i+ 0.001;
Double_t res = graph2d->Interpolate(pt,eta);
Double_t res2 = dt->ComputeZ(pt, eta);
Double_t res3 = dt->Interpolate(pt, eta);
std::cout << eta << " " << res << " " << res2 << " " << res3

Output differs slightly, but in general look like this:
1.85 14 14 0
1.86 0 0 0
1.87 0 0 0
1.88 0 0 0
1.89 0 0 0
1.9 0 0 0
1.91 0 0 0
1.92 0 0 0
1.93 0 0 0
1.94 0 0 0
1.95 0 0 0
1.96 0 0 0
1.97 14.4 14.4 0

Thanks a lot for your help!
best
Andreas
bestGuessV4.C (101 KB)

Hi,

I suspect what you observe is due to the fact that your points are distributed in a Grid and they are not random.
This is a known limitation of the current algorithm, and we hope to improve it in the future. However, if you have (x,y) points equally spaced, used the interpolations of the 2D Histogram (TH2)

Best Regards

Lorenzo

1 Like

Dear User/Devloper,

I’m getting same zero problems for TGraph2D -> Interpolate
TGraph2D_Interpolate_zeroError.tar.gz (11.0 KB)

Basically, I’m using Honda Neutrino Flux for INO site (with out mountain avg. azimuthal) and trying to produce a rough calculation of #muon event via CC, with DIS Fe56 scattering using its crossection.
for that I need interpolation on 2D Honda Flux(E,Zenith)
I am using root-v6-18-04@v6-18-04 version (the latest one).
Please suggest me what to do in this regard.

best regards,
sadashiv
INO