I need a Random Number Generator that is:

1) certifiably random (NOT pseudo random)

2) has a Java Interface

3) can generate 1000 numbers per second of the format 1to N where N = {4,6, 136,144}

I know that I can get a C++ library and build my own Java interface. I also know that I can certify the implementation with a testing lab myself.

I simply want a one stop solution that provides me with a truly random stream of numbers accessible from Java. I don't mind being tied to an Intel board or processor.

Does anyone have some ideas? I cannot be the first person who needed a random number generator in Java.

Thanks,

Neil

# Random Number Generator and Java

## Random Number Generator and Java

For more complete information about compiler optimizations, see our Optimization Notice.

Thanks for joining the MKL forum. I am asking the developers for VSL, the MKL statistical library includign random number generators, to respond to you inquiry.

Bruce

Truly random RNG's hardly exist, partly because it's extremely difficult to make sure they are truly random. One approach that has been used is to look at a low-order bit in the system clock, but that has the drawback that your code may execute faster than the clock, giving you correlated bits. Also, if there is any synchronicity between the system clock and the processor's clock you can get into trouble.

I see your e-mail address is "mahjongmania.com" so I presume that you need this for randomizing a shuffle in a game (presumably mah jong :). For these sorts of purposes, a psuedo-random generator usually is fine. If you are worried about repeat times or correlations, you might want to look into the Mersenne Twister RNG (http://www.math.sci.hiroshima-u.ac.jp/%7Em-mat/eindex.html).

You can make sure a RNG doesn't give the same sequence on different start-ups by initializing it using something like the system clock, which is very likely to be different every time someone starts up your application.

Hope this helps,

John Weeks

Software implementations of random number generators generate deterministic and periodic sequences of numbers. Thus such sequences can be hardly called random. In fact, such implementations just imitate randomness. Wording pseudo-random accentuates deterministic nature of a sequence rather than emphasizes bad random properties of the generator.

There are many software implementations of random number generators, and it's impossible to recommend particular RNG as the best one. All RNGs differ in their properties (period length, speed, uniformity measures like equidistribution and discrepancy as well as ... unpredictability). I would say that user application defines requirements to RNGs. For instance, some Monte Carlo methods (like MC integration) require just filling a space of required dimension as even as possible and don't require independence between random vectors. There are generators specially designed for such purposes. They are called quasi-random number generators.

For majority of applications utilizing random numbers it's sufficient to use pseudorandom number generators. In contrast to quasi-random ones they imitate independence as well. I would recommend trying pseudo-or quasi-random number generator solutions from Intel Math Kernel Library. In particular, MKL provides comprehensive documentation discussing RNG applicability aspects, theoretical properties, performance measurement results and empirical testing results for each RNG available in MKL. Perhaps you can find there something applicable to you.

If Java implementations are the most preferable to you, however, I would recommend following links:

1) One of the best pseudo-random number generators (Mersenne Twister)

http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html

(Java versions of the generator can be found at http://www.cs.umd.edu/users/seanl/gp/, http://www.spaceroots.org/downloads.html).

2) You may want to look at Java package RngPack. It has some RNGs including Mersenne Twister (http://www.honeylocust.com/RngPack/).

3) You may find also interesting links at http://www.cs.berkeley.edu/~daw/rnd/.

One of RNG properties might be important (i.e. in cryptography) is unpredictability of the output. This means that without knowledge about RNG algorithm and looking only on previously generated output an observer cannot predict next number with probability higher than 50%. Unfortunately there is no proven algorithm satisfying such a requirement. Output of most of pseudo-random number generators can be _relatively_ easy predicted.

Regarding to true randomness. There are specially designed physical devices which output is a combination of an analog noise and a deterministic algorithm. I would recommend following link href="http://www.intel.com/design/chipsets/rng/CRIwp.pdf" target=_blank>http://www.intel.com/design/chipsets/rng/CRIwp.pdf. But those generators may have some shortcomings (e.g an absence of reproducibility of a sequence).

A little bit more about "true" randomness. Pseudorandom number generators can be rather unpredictable if you will reinitialize them from time to time using processor clock. The only recommendation is to do this relatively rare (much rarely than the rate of a processor clock).

Andrey