Generating sequences of random numbers or bits is a necessity in many situations (cryptography, modeling, simulations, etc…). Those sequences must be random in the sense that their behavior should be unpredictable. For example, the security of many cryptographic systems depends on the generation of unpredictable values to be used as keys. Since randomness is related to the unpredictable property, it can be described in probabilistic terms, studying the randomness of a sequence by means of a hypothesis test. A new statistical test for randomness of bit sequences is proposed in the paper. The created test is focused on determining the number of different fixed length patterns that appear along the binary sequence. When ‘few’ distinct patterns appear in the sequence, the hypothesis of randomness is rejected. On the contrary, when ‘many’ different patterns appear in the sequence, the hypothesis of randomness is accepted.

The proposed can be used as a complement of other statistical tests included in suites to study randomness. The exact distribution of the test statistic is derived and, therefore, it can be applied to short and long sequences of bits. Simulation results showed the efficiency of the test to detect deviation from randomness that other statistical tests are not able to detect. The test was also applied to binary sequences obtained from some pseudorandom number generators providing results in keeping with randomness. The proposed test distinguishes by fast computation when the critical values are previously calculated.