Tool for randomness testing of data.
For a more detailed explanation, refer to paper/documentation.pdf. (in Bulgarian)
> git clone https://github.com/renegat96/randest/
> cd randest/
> cd src/
> mkdir bin
> g++ -std=c++11 -Wall -O2 main.cpp -o bin/randest -Iinclude -lgmp -lgmpxx
> g++ -std=c++11 -Wall -O2 lcg.cpp -o bin/lcg -lgmp -lgmpxx
Another way to build Randest is by using CodeBlocks. One should add the include/ directory in the include path by the compiler options in the IDE.
It is very important to turn C++11 support on. Unless so, there will be compile errors.
A thought worth considering is installing Cygwin and referring to the previous section.
usage: randest --int|--double
[--stdin|--binary-file path]
--kstest |
--freqinterval lower upper |
--freqpresent |
--coupon n t upper |
--maxtest groupsize |
--monotone t [--increasing|--decreasing] |
The first argument should always be either "--int" or "--double" to specify the type of data input.
What may follow is a specification of what is the source of data. Default value is --stdin. As of now only two modes are supported. It is possible to adjust the cache size when reading from a file, though it requires modifying the source.
The last option is the test to be run. Specify exactly one test with all its parameters. An exception is the monotone test - whether to examine increasing or decresing subsequences defaults to increasing, if not explicitly stated otherwise.
The following execution of Randest will try to read the given file in binary mode, take as many long long variables and apply a chi-squared test on the resulting sequence:
> randest --int --binary-file file/with/binary/string --freqpresent
Another way to use it is shown here. This would read doubles from standard input as long as there are some and then give the Kolmogorov-Smirnov statistic of the sequence. Piping allows reading from a file.
> randest --double --stdin --kstest < file/with/a/sequence/of/doubles
And the last example given here is this:
> randest --int --stdin --coupon 100000 400 100 < file/with/nonnegative/integers/less/than/100
This parametrization of the coupon-collector's test is as follows:
- the collector will take at most 100000 collections;
- all collections larger than 400 items will be considered 400 of length;
- the input to the test is less than 100.
In order to examine the results of different tests and reproduce them a few files have been written. To use them, one has to go to the src/tests/ directory and execute any of the given files.
For a given linear congruential generator the spectral test will be executed. As a comparison, the K-S test over 1 000 000 generated by the generator will be run also. The sequence will be stored in a file called src/tests/generated.
Overall, one should expect a very good performance of the generators on the K-S test by all LCGs. Due to weaknesses though, most of the generators will fail the spectral test.
This requires bash, thus Linux or Cygwin.