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

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 26 08:45:53 PST 2016


On 02/26/2016 10:19 AM, Alex Parrill wrote:
> On Friday, 26 February 2016 at 14:59:43 UTC, Andrei Alexandrescu wrote:
>> On 02/25/2016 06:46 PM, Nicholas Wilson wrote:
>>> 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
>>
>> Thanks, that's indeed closest! A hefty read. Anyone inclined to work
>> on a PCG random implementation? -- Andrei
>
> Beat you to it: http://code.dlang.org/packages/d-pcg
>
> It only has the basic generators at the moment. I'll look into the more
> advanced stuff.
>
> (Also 64 bit outputs aren't implemented yet because they need a 128 bit
> uint for state. I noticed D reserves the names cent and ucent but hasn't
> implemented them)

That's pretty darn cool! I don't see a way to create a generator given a 
range expressed as a power of two. Say e.g. a client wants to say "give 
me a generator with a cycle of 32768". Is this easily doable?

Also: when the generator starts running, does it generate a full cycle, 
or it starts with a shorter cycle and then settle into a full cycle?


Thanks,

Andrei



More information about the Digitalmars-d mailing list