-
-
Notifications
You must be signed in to change notification settings - Fork 441
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
Improve calculation of the scale
parameter for the uniform float distribution.
#1301
Improve calculation of the scale
parameter for the uniform float distribution.
#1301
Conversation
Quick question from a bird's eye perspective: |
In the few tests that I did, In the meantime, I'm marking this PR as draft. |
Hello - sorry for the late comment. I don't have an example off the top of my head, but I can say that I saw the same behaviour with new_inclusive (but with different constants). |
@WarrenWeckesser is this still on your to-do list? |
Looking at this again... I don't think attempting to hack the bounds like this is worth it. Take a look at the comments in the "Notes" section of https://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution. In particular, follow the links to the bug reports for the various C++ compilers. I think it is useful to have a standard uniform distribution on the half-open interval [0, 1), and that can be done reliably, but handling all the edges cases of the general uniform distribution on [a, b) where it is guaranteed that b will not be generated while maintaining the uniform probabilities of the points near the boundary b and ideally ensuring that the algorithm consumes a fixed number of samples from the underlying PRNG (i.e. no looping for an indefinite number of iterations) is a more involved problem than I can work on now. |
Thanks for taking another look at this @WarrenWeckesser. Then I think we go for #1462. |
The calculation of
scale
for the uniform float distribution is moved to its own function and updated to avoid the problem that was pointed out in gh-1299. As part of the new implementation, the new utility methodslt_mask()
,increase_masked()
andutils_next_down()
are added to theFloatSIMDUtils
traits.The improved method for computing the scale is explained in the comments in the function
compute_scale()
.