Apache Commons logo Apache Commons RNG

Apache Commons RNG: Random Numbers Generators

Commons RNG provides implementations of pseudo-random numbers generators that are either faster or of higher quality (and sometimes both) than java.lang.Random.

Casual use is as simple as:

import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.RandomSource;

// Instantiate a "Mersenne-Twister" generator with a factory method.
UniformRandomProvider rng = RandomSource.create(RandomSource.MT);

// Use it to produce a floating-point value between 0 and 1.
double random = rng.nextDouble();

For more examples and more advanced usage, see the userguide.

Download Apache Commons RNG

Releases

Download the Latest Release of Apache Commons RNG.