Pseudo-random numbers in [0, n), covering all numbers in n steps?
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Thu Feb 25 09:27:25 PST 2016
So we have https://dlang.org/phobos/std_random.html#.randomCover which
needs to awkwardly allocate memory to keep track of the portions of the
array already covered.
This could be fixed by devising a PRNG that takes a given period n and
generates all numbers in [0, n) in exactly n steps.
However, I've had difficulty finding such PRNGs. Most want the maximum
period possible so they're not concerned with a given period. Any insights?
BTW I found this statement in the documentation rather odd: "These
issues will be resolved in a second-generation std.random that
re-implements random number generators as reference types." The
documentation is not a place for making vague promises and speculations
about future developments. I think it should be removed.
Thanks,
Andrei
More information about the Digitalmars-d
mailing list