Hi all,
Possibly really basic problem. I can’t figure out how to get TF1::GetRandom() to return a different sequence of numbers when I run it. I compile my code as an executable and run it outside of the Interpreter environment, by the way.
So I wrote my own simple function to define a TF1*, shown below
[code]double SampleGaus(double mean, double sigma)
{
TF1* gausFunction = new TF1(“gaussian”, “gaus(0)”, 0, 850);
gausFunction -> SetParName(0, “norm”);
gausFunction -> SetParName(1, “mean”);
gausFunction -> SetParName(2, “sigma”);
gausFunction -> SetParameter(0, 1);
gausFunction -> SetParameter(1, mean);
gausFunction -> SetParameter(2, sigma);
return gausFunction->GetRandom();
}
[/code]
and in my main() function I call SampleGaus() multiple times in a for loop. Every time I run the executable, the sequence of “random samples” from SampleGaus() is the same. When I increase the number of iterations in the for loop, the returns are random but the sequence always repeat when I re-run the executable.
I have tried setting TRandom3 r(0) (illustrated here: Randomness of TF1::GetRandom() Function) in the function SampleGaus() and in main() to no avail. Any thoughts?