Solved – NIST randomness test fails in random generated bits

I am using the NIST randomness test suite which checks whether a bit sequence is random over 15 different tests. I have problems in verifying if this suite works fine. The situation is that if I input, for example, 10000 sequences of the same length (e.g., 1000) and generated by rand function of MATLAB, sometimes it passes the basic tests I use, i.e., frequency, runs, block frequency, cumulative sums. However, sometimes it fails the basic frequency test and cumulative sums test in terms of p-value of p-values but not in terms of proportion.

I have two questions. The general one is how can I generate uniformly distributed random bits from MATLAB? The second is, why the problem mentioned above happens in NIST randomness suite, can anyone help me to verify if it works fine?

For reference document :

Keep in mind: Dilbert on random numberssource

Sounds like you are repeating the experiment. In that case, even for truly random numbers you have to expect a number of failures that corresponds to the specified p-value.

What about getting some truly random numbers (e.g., or HotBits or the like) and trying those to get a baseline against which you can compare the matlab generator? As you'll need many random bits (far more than the free allowance) you'll probably write them and ask nicely.

I also like the discussion of testing for randomness at, which besides the general ideas and caveats also links to a report on their random number generation using the NIST tests. HotBits of cousre has a random number statistics page as well.

By the way, browsing through the report I read that for the NIST tests 5.5e6 random numbers are recommended for the testing. If I understand your setup correctly, you were running with 1e4, so a factor 50 below the recommendation.

Similar Posts:

Rate this post

Leave a Comment