# How can I test the quality of a RNG?

On electronics.stackexchange we had a question about constructing a True Random Number Generator. Since the method relies on noise, which isn't deterministic, the only way to test the quality of the RNG seems to be empirical.
Not being a statistician I suggested to test a long bit sequence for normality, but I have no idea what outcome is acceptable and what isn't. For instance counting single bits I guess we have a thumbs-up for a 499500/500500 distribution, but when is the ratio too much skewed to be acceptable? Same for 2-bit and longer sequences.
Of course, if testing for normality is a Bad Idea™, I'd like to hear it, including better alternatives.

edit
Diehard was mentioned a few times, but I'm not sure this answers my question. The normality test should give a normal distribution, with better bell curve approximations for longer sequences. Diehard seems also to have tests which either should result in normal or exponential distributions. But my question remains: how do I judge the results? Just by looking at the curve and discern a bell curve in it? To get back at my first example, a 499500/500500 distribution is definitely OK, and a 950000/50000 distribution definitely is a no-no, so where does the switch-over happen?

-
Have you seen Diehard? –  Ｊ. Ｍ. Sep 14 '11 at 16:26
If I recall correctly, Volume 2 of the Art of Computer Programming has a lot on this subject, though it may be out of date. –  David Speyer Sep 14 '11 at 17:14

## migrated from math.stackexchange.comSep 14 '11 at 17:16

This question came from our site for people studying math at any level and professionals in related fields.

J.M. already mentioned the original Diehard battery of tests by George Marsaglia. As far as I know, this test set is no longer being maintained.

Robert Brown has been working for years on DieHarder which is

• a GPL'ed reimplementation of the DieHard suite
• plus additional tests from the NIST suite
• plus development of new tests

and you may find DieHarder useful.

-