Module TestU01.Bbattery
Bbattery
This module contains predefined batteries of statistical tests for sources of random bits or sequences of uniform random numbers in the interval [0,1). To test a RNG for general use, one could first apply the small and fast battery SmallCrush
. If it passes, one could then apply the more stringent battery Crush
, and finally the yet more time-consuming battery BigCrush
.The batteries Alphabit
and Rabbit
can be applied on a binary file considered as a source of random bits. They can also be applied on a programmed generator. Alphabit
has been defined primarily to test hardware random bits generators. The battery PseudoDIEHARD
applies most of the tests in the well-known DIEHARD suite of Marsaglia. The battery FIPS-140-2
implements the small suite of tests of the FIPS-140-2 standard from NIST.
The batteries described in this module will write the results of each test (on standard output) with a standard level of details (assuming that the boolean switches of module Swrite
have their default values), followed by a summary report of the suspect p-values obtained from the specific tests included in the batteries. It is also possible to get only the summary report in the output, with no detailed output from the tests, by setting the boolean switch Swrite.set_basic
to false
.
Some of the tests compute more than one statistic using the same stream of random numbers and these statistics are thus not independent. That is why the number of statistics in the summary reports is larger than the number of tests in the description of the batteries.
SmallCrush
val small_crush : Unif01.gen -> unit
val small_crush_file : string -> unit
val repeat_small_crush : Unif01.gen -> int array -> unit
Crush
val crush : Unif01.gen -> unit
val repeat_crush : Unif01.gen -> int array -> unit
Similar to
repeat_small_crush
above but applied onCrush
.
BigCrush
val big_crush : Unif01.gen -> unit
val repeat_big_crush : Unif01.gen -> int array -> unit
Similar to
repeat_small_crush
above but applied onBigCrush
.
Rabbit
val rabbit : Unif01.gen -> float -> unit
Applies the
Rabbit
battery of tests to the generatorgen
using at mostnb
bits for each test. See the description of the tests inrabbit_file
.
val repeat_rabbit : Unif01.gen -> float -> int array -> unit
Similar to
repeat_small_crush
above but applied onRabbit
.
Alphabit
val alphabit : Unif01.gen -> float -> int -> int -> unit
alphabit gen nb r s
applies theAlphabit
battery of tests to the generatorgen
using at mostnb
bits for each test. The bits themselves are processed as blocks of 32 bits (unsigned integers). For each block of 32 bits, the r most significant bits are dropped, and the test is applied on the s following bits. If one wants to test all bits of the stream, one should set r = 0 and s = 32. If one wants to test only 1 bit out of 32, one should set s = 1. See the description of the tests inalphabit_file
.
val repeat_alphabit : Unif01.gen -> float -> int -> int -> int array -> unit
Similar to
repeat_small_crush
above but applied onAlphabit
.
BlockAlphabit
val block_alphabit : Unif01.gen -> float -> int -> int -> unit
val block_alphabit_file : string -> float -> unit
val repeat_block_alphabit : Unif01.gen -> float -> int -> int -> int array -> int -> unit
Similar to
repeat_small_crush
above but applied onBlockAlphabit
. The parameter w is the one described inblock_alphabit
. Restrictions: w ∈ {1,2,4,8,16,32} and w≤s.
PseudoDIEHARD
val pseudo_diehard : Unif01.gen -> unit
NIST
The NIST (National Institute of Standards and Technology) of the U.S. federal government has proposed a statistical test suite for use in the evaluation of the randomness of bitstreams produced by cryptographic random number generators. The test parameters are not predetermined. The NIST tests and the equivalent tests in TestU01 are:
- The Monobit test. This corresponds to
Sstring
.hamming_weight_2 with L = n. - The Frequency test within a Block. Corresponds to
Sstring
.hamming_weight_2. - The Runs test. Is implemented as
Sstring
.run. - The test for the Longest Run of Ones in a Block. Is implemented as the test
Sstring
.longest_head_run. - The Binary Matrix rank test. Is implemented as
Smarsa
.matrix_rank. - The Discrete Fourier Transform test. Is implemented as
Sspectral
.fourier_1. - The Non-overlapping Template Matching test. Is implemented as the test
Smarsa
.cat_bits. - The Overlapping Template Matching test. This test does not exist as such in TestU01, but a similar and more powerful test is
Smultin
.multinomial_bits_over. - Maurer’s Universal Statistical test. This test is implemented as
Svaria
.appearance_spacings. - The Lempel-Ziv Compression test. Is implemented as
Scomp
.lempel_ziv. - The Linear Complexity test. Is implemented as part of
Scomp
.linear_comp. - The Serial test. Corresponds to
Smultin
.multinomail_bits_over with Delta = 1. - The Approximate Entropy test. Corresponds to
Smultin
.multinomial_bits_over with Delta = 0, and toSentrop
.entropy_disc_over orSentrop
.entropy_disc_over_2. - The Cumulative Sums test. This test is closely related to the M statistic in
Swalk
.random_walk_1. - The Random Excursions test. This test does not exist in TestU01, but closely related tests are in
Swalk
.random_walk_1. - The Random Excursions Variant test. This test does not exist in TestU01, but a closely related test is based on the R statistic in
Swalk
.random_walk_1.
FIPS-140-2
val fips_140_2 : Unif01.gen -> unit
val fips_140_2_file : string -> unit