-
Notifications
You must be signed in to change notification settings - Fork 431
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
Uniform Generator hangs for certain limits. #1299
Comments
The "hang" is actually this loop rand/src/distributions/uniform.rs Lines 861 to 867 in 0f3eced
taking a very long time to complete. That loop will require roughly
The problem is that in the loop, |
FYI: NumPy has an issue about their uniform generator claiming to generate variates in |
Floating point rounding is not a great excuse, it's easy to fix returning (FWIW, I ran into similar issues with the C++ standard libraries.) |
I agree with whatr @vks, but in addition, I'd rather it return high than hit this degenerate case, having to wait for two hours. |
To be clear, this reported bug is not something we should just document and ignore. The least intrusive fix would probably be to calculate a more precise decrement. Uniform implements sampling for both Complication: |
I think I have a fix. Once I work out one particular edge case, I'll submit a pull request. |
Fix #1299 by removing logic specific to ensuring that we emulate a closed range by excluding `high` from the result.
See here for a MWE:
https://github.com/GUIpsp/rand_uniform_hang/blob/main/src/main.rs
I also tested that #1287 does not fix this issue.
The text was updated successfully, but these errors were encountered: