Apache Commons logo Apache Commons RNG
Apache Commons RNG Simple ™
  • Last Published: 09 July 2024
  • |
  • Version: 1.6

Apache Commons RNG: Random Numbers Generators

Commons RNG provides implementations of pseudo-random numbers generators that are faster; of higher quality; and/or of a longer period than java.util.Random and java.util.SplittableRandom.

The "simple" module contains factory methods for easy instantiation of the generation algorithms implemented in the "commons-rng-core" module.

Example:

import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
public class Dice {
 private final UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create();
 public int roll() {
 return 1 + rng.nextInt(6);
 }
}

Browse the Javadoc for more information.

Copyright © 2016-2024 The Apache Software Foundation. All Rights Reserved.

Apache Commons, Apache Commons RNG Simple, Apache, the Apache feather logo, and the Apache Commons project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.

AltStyle によって変換されたページ (->オリジナル) /