My favorites | Sign in
Project Logo
                
Code license: New BSD License
Labels: java, random, PRNG
Show all Featured downloads:
javarng-1.0.2.tar.gz
People details
Project owners:
  nickgsuperstar

com.modp.random

This package contain some unusual generators based on normal numbers and cellular automata as well as some old classics. These are designed to be used for research, and not as a replacement to the stock Random (which is fine for what it is). All of these should not be used for cryptography (SecureRandom is fine as is).

The Generators

LinearSunJDK The same algorithm as in com.util.Random but without synchronization
BlumBlumShub a 'cryptographically-secure' generator in which predicting the next bit is computationally equivalent to integer factorization.
Rule30, 192 Cells Rule 30 celluar automaton using 192 cells
Mersenne Twister a high speed and high quality generator with period 219937-1
Mersenne Twiser 64 Similar to the original but implemented using 64-bit registers.
Bailey-Crandall this is unusual in that it uses high-percision floating point computations to generate random bits.

Detailed notes and references in are in the source. javadoc output is here

With the exception of BlumBlumShub, all come with unit tests to insure that the algorithm is implemented correctly.

TODO:

Introducing `RandomGenerator`

Ok, so a Random Number Generator, should generate bits, and bits only. It's an interface. It has one method.

public interface RandomGenerator {
   public int next(int numBits);
} 

That's it. How the generator is constructed, seeded or re-seeded is up to the generator. This greatly simplifies class construction since you don't worry about calling super() or worrying about synchronization.

Java and Random Number Generation

And so, why Java? A few positive reasons first

On the other hand, I don't use java that much any more (whoops). At some point I may write a C/C++ version and add it to Boost or the GNU Scientific Library.

Problems with `java.util.Random`

That said, the stock java.util.Random and it's twin java.security.SecureRandom have some problems.









Hosted by Google Code