uniform_real_distribution should use uniform_int_distribution
- Dominant language
- C++
- Stars
- 42
- Forks
- 76
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 5
Description
Hello again!
`generate_uniform_real` for `is_integral == true` should probably do something like this (pseudo code):
auto dist = uniform_int_distribution( unsigned long min, unsigned long max );
auto numerator = dist(eng);
auto divisor = unsigned long max;
[...]
instead of using:
result_type numerator = static_cast(subtract()(eng(), (eng.min)()));
result_type divisor = static_cast(subtract()((eng.max)(), (eng.min)())) + 1;
[...]
The current implementation fails to produce more different values than the range of the Engine is able to give. E.g., a PRNG which only ever produces values in the range [0..1] would lead to returning only 2 different real values.
What are your thoughts about this?
Best regards,
Dominik
PS: I noticed this when using good ol' `rand()` as an Engine behind the scenes.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.