# Problem with TF3::GetRandom3

Hello everyone,

I’m facing a strange problem with TF3::GetRandom3 with ROOT 5.34.30.
When applying this method (e.g. with f->GetRandom3(x,x,x)), I get the following error message :

Error in TF3::Integral: Must be called with a TF2 only
Error in TF3::CentralMoment2: Integral zero over range

And the returned values are all 0. The funny thing is that this worked perfectly with my previous ROOT version, 5.34.18.

Here’s a more precise example:

double gaus3d(double x, double p) { // example function from which draw random numbers
double sigma_x = p;
double sigma_y = p;
double sigma_z = p;
double rho = p;
double u = x / sigma_x ;
double v = x / sigma_y ;
double w = x / sigma_z ;
double c = 1 - rho
rho ;
double result = (1 / (2 * TMath::Pi() * sigma_x * sigma_y * sigma_z * sqrt©))
* exp (-(u * u - 2 * rho * u * v + v * v + w
w) / (2 * c));
return result;
}

int n = 100;
TF3 * f = new TF3(“g3d”,gaus3d,-10,10,-10,10,-10,10,4);
f->SetNpx(200);
f->SetNpy(200);
f->SetNpz(200);

double par = {2,2,2,0.5};
double x = {0,0,0};
f->SetParameters(par);
for (int i = 0; i < n; ++i) {
f->GetRandom3(x,x,x);
}

Does anyone have an idea of how to fix this?

Thanks!
Vincent

Hi,

I don’t have any problem running this code with 5.34.31 and also with ROOT 6 versions

Best Regards

Lorenzo

Hi,

Thanks for your answer. On what OS have you done the test? It seems that the problem is Mac OS - related.
I’m facing the issue with Mac OS X 10.8.5, but I don’t have any problem when using a Linux distribution (e.g. Mageia).

Vincent

Hi,

I have tested on MacOS 10.10.3. But I doubt that this problem is due to the OS version. It could be due to a wrongly built version of ROOT.
I would try to re-build and re-install ROOT, possibly using the latest version of 5.34 or 6.

Cheers

Lorenzo