vendredi 4 juin 2021

How can I test a floating-point random number generator?

I've written a Java class for 128-bit floating-point arithmetic. Among other methods, it has a method intended to generate a pseudo-random value in the range [0, 1.0). Although I use the standard java.util.Random class that I consider reliable enough, the way I construct the value of my Quadruple class from it, may occur erroneous. So I'd like to make sure that the random values it returns are random enough. I've checked the distribution of the magnitudes over 10_000 subranges with the Chi-Square criteria, and checked the frequencies of 1 in each bit position of the mantissa, and I've looked at the hexadecimal representations of the numbers with the naked eye, that's all I could think of. So far everything looks quite well.

But these tests don't check many other possible flaws of the pseudo-random numbers (say, a potentially possible correlations between the bits of the mantissa or simply repetition of a short sequence of values). Are there any ways to test a sequence of such numbers more carefully and comprehensively? In case it's relevant to the question, the value of a number of this type is internally stored as 128 bits (two longs) of the mantissa and 32 bits of the exponent.




Aucun commentaire:

Enregistrer un commentaire