Pseudo-random numbers in [0, n), covering all numbers in n steps?

Nicholas Wilson via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 25 15:46:04 PST 2016


On Thursday, 25 February 2016 at 17:27:25 UTC, Andrei 
Alexandrescu wrote:
> 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

The technical name for the property of distribution you describe 
is
  k-Dimensional Equidistribution (in this case k=1).
I would suggest taking a look at http://www.pcg-random.org.
They claim to have both arbitrary period and k-Dimensional 
Equidistribution

Nic



More information about the Digitalmars-d mailing list