On 25/08/13 22:30, bearophile wrote:
Before being merged into Phobos someone has to measure a bit the actual quality
of the random numbers it produces. To avoid problems like the ones had with
Xorshift. There are suites and tools to measure the quality of random numbers,
like a more modern version of the famous diehard.

Diehard is out of date. There's the Dieharder suite, and there's another by Pierre L'Ecuyer and colleagues, TestU01:
http://www.phy.duke.edu/~rgb/General/dieharder.php
http://www.iro.umontreal.ca/~simardr/testu01/tu01.html

Dieharder is in the repositories of Debian/Ubuntu, and a first approximation of a D random test suite is probably as simple as writing a D program that outputs a sufficient quantity of random numbers, and piping them through to Dieharder. It's on the TODO list but there have been too many other things going on recently. :-P

By the way, the Xorshift problem didn't need a complicated test suite. This was the code that showed up the problem:

writeln("Let's test the uniformity of random numbers produced with different RNGs.");
    size_t n = 1000_000;

    foreach(Rng; PseudoRngTypes)
    {
        writeln("Generating ", n, " random numbers in [0, 1) with ", 
Rng.stringof);
        auto rng = Rng(unpredictableSeed);
        auto dist = Distribution(0.0, 100.0, 20);
        foreach(i; 0 .. n)
        {
            dist.add(uniform(0.0, 100.0, rng));
        }

        foreach(bin, h, c; dist.distribution)
        {
            writeln("\t", bin, "\t", h, "\t", c);
        }
        writeln;
    }

(A few data structures aren't described here, but you get the idea.)

The Xorshift problem only arose because the reference code was itself buggy. For something like Lagged Fibonacci there are already good and battle-tested implementations out there (e.g. Boost.Random) and a comparison of results for the same seeds should be sufficient for inclusion.

Reply via email to