Random from interpolated TGraph2D

Hello,
I have a some fairly coarsely distributed points in a TGraph 2D, and I’d like to use a simple interpolation (linear is fine) then pull random points from the result - along the lines of the GetRandom2 method in TH2, but using the interpolation.
Any suggestions on how to do this?
thanks!


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


I guess you can get random points in the X,Y plane of your TGraph2D and for each of them retrieve the Z value using Interpolate.

Thanks - but I was hoping to draw points with a probability based on the (interpolated) z-axis value. I can always hack something together based on your suggestion, but wondered if this functionality already existed for TGraph2D - the interpolation etc is already there.

TGraph2D does not have the GetRandom2 method like TH2. But it has GetHistogram which returns a TH2D produced thanks to the Delaunay triangles of the TGraph2D. So you can use GetRandom2 on the TH2D returned by GetHistogram.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.