The present invention is a method and apparatus for testing random numbers generated
by a random number generator in real time. A stream of random bits is generated
using said random number generator, then the generated random bits undergo a gap
length calculation operation in which all sub-sequences having identical bit patterns
are identified and the resulting gap lengths are applied to exponential averaging
to obtain average gap lengths between identical bit patterns. The average gap lengths
are compared to at least one predetermined acceptance range, so that if at least
one of the average gap lengths falls repeatedly outside the predetermined acceptance
range more than a predetermined number of times, it is determined that the generated
random bits are insufficiently random.