GetRandom() behavior

Hello,

I am using GetRandom() to fill a histogram with a pre-defined distribution, Lorenzian, or Gausian in the attached example.

test.cpp (5.3 KB)

The results are unexpected.

1.) For even center values and large widths it is sort of fine, see h1

2.) If the center value is odd the resulting distribution is wrong, see h2

3.) If the width is small, wrong distribution again, see h3

Please note that I am using 5.28 for compatibility reasons and this may not be an issue in later versions.

In reproducer you sent (test.cpp). I did not find any occurrence of the string “Random”. May be you posted the wrong file ?

test.cpp (1.8 KB)

Sorry, here it is.

1 Like

peak->SetNpx(3 * (peak->GetXmax() - peak->GetXmin()) / h1->GetBinWidth(1) + 0.5); // e.g., 2* or 3* or 5* (but at least 1*)

BTW. From my point of view, it’s a bug that the GetRandom doesn’t automatically use something like this.

Excellent! Thank you.