KilianB / pcg-java

PCG — Java Implementation. High quality fast random number generator
MIT License
11 stars 4 forks source link

How can I use the PractRand with your code? #3

Closed menwn closed 5 years ago

menwn commented 5 years ago

Could you please give an example on how to use the PractRand with your library to test the outcome?

KilianB commented 5 years ago

The file https://github.com/KilianB/pcg-java/blob/master/src/main/java/com/github/kilianB/statBenchmark/PractRandInterface.java was used to call the practRand.exe .

The command line parameters can be found at their homepage: http://pracrand.sourceforge.net/

If you need any additional information go ahead and ask ;).

menwn commented 5 years ago

Thank you. I was able to use this file to understand what you do. Great job. However one thing is that if I use nextInt(10) (or any integer as upper limit that I tested) I get failure from the PractRand. I am not sure why this is the case. I would expect that it would pass. Or is this a case where the space is too little to be used by PractRand?

KilianB commented 5 years ago

Without taking a look at pract rand one of the tests probably checks the individual bit distribution of the supplied numbers and expects a known distribution.

If you only supply values up to 9 , you will pass values starting from 0000000000000000 to 0000000000001001 to the algorithm (a few leading zeros more or less). Since the high bits are always 0 it assumes that the random numbers are not randomly distributed.

You might get lucky by modifying bitsPerData to the correct 2 complement of the number you choose e.g. set bitsPerData to 4 and compute random numbers up to 15 since 1111 = 15. Maybe you can then pass the computed value converted to bytes to the program. Not tested but should be possible.

menwn commented 5 years ago

Thank you