-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Removed skipping of 0 (zero) in TRandom3.Rndm() #14702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Can one of the admins verify this patch? |
@phsft-bot build |
Starting build on |
Hello: for me this PR is good to go @lmoneta ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @lmoneta have a look when you can
The PR looks good. The doubt I have is that there is a change in functionality. In ROOT, all random generators of |
@phsft-bot build |
Starting build on |
Build failed on ROOT-ubuntu2004/python3. |
Adding +1 to the generated int which is equal to int_max will result again in 0 (zero), no? |
math/mathcore/src/TRandom3.cxx
Outdated
if (y) return ( (Double_t) y * 2.3283064365386963e-10); // * Power(2,-32) | ||
return Rndm(); | ||
// 2.3283064365386963e-10 == 1. / (max<UInt_t> + 1) -> then returned value cannot be = 1.0 | ||
return static_cast<Double_t>(y * 2.3283064365386963e-10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add the +1 here after converting to double to avoid overflows in the uint:
return (static_cast<Double_t>(y) + 1)* 2.3283064365386963e-10)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overhead of adding a +1 should be minimal. We could test running tutorial/math/testRandom.C
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjvbrt could you take care?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm testing the implementation with +1 ATM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the result:
TRandom3 TRandom3 with +1
Rndm.............. 20.000 20.000
RndmArray......... 10.000 15.000
Gaus.............. 60.000 60.000
Rannor............ 40.000 40.000
Landau............ 40.000 40.000
Exponential....... 35.000 35.000
Binomial(5,0.5)... 125.000 130.000
Binomial(15,0.5).. 370.000 380.000
Poisson(3)........ 90.000 95.000
Poisson(10)....... 205.000 210.000
Poisson(70)....... 295.000 300.000
Poisson(100)...... 295.000 295.000
GausTF1........... 180.000 180.000
LandauTF1......... 175.000 175.000
@phsft-bot build |
Starting build on |
Test Results 12 files 12 suites 2d 3h 59m 38s ⏱️ For more details on these failures, see this check. Results for commit f501b84. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes of this PR seem to trigger many errors in our CI. I will remove my approval pending a fix for the tests
This Pull request: Removes skipping of 0 (zero) in TRandom3.Rndm()
Changes or fixes:
Checklist:
This PR fixes #14581