www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Simple test suite for std.random

Hi all,

I'm preparing a few very simplistic test functions for std.random.  These are
not so suitable for unittests as they are basically to check that random values
are being generated in the correct proportions, etc.:

Actually, right now the ONLY test is a pretty simple one for RandomSample, to
check that it selects from its input in the correct proportions.  It's really
basic and is just there as a visual check to make sure nothing is obviously

I'm posting now, rather than when a few more tests are in place, because this
has already thrown up a few incongruities and I want to make sure I'm not
missing something stupid.

Problems identified so far:

    (i) The two RNGs based on the linear congruential engine, MinstdRand0 and
        MinstdRand, both cause systematic distortions in the sampling process,
        biasing against the last values in the input.

   (ii) Xorshift32 has a very weird bias when sampling from small sizes: it
        selects almost entirely from the second half of the input.  The
        program freezes when Xorshift32 is used to sample from large sizes.

Any thoughts/remarks?  I'm going to keep looking into this, but thought I'd
check if anyone sees any obvious reasons.

Thanks & best wishes,

     -- Joe
Jul 04 2013