Interface RandomNumberGenerator

All Known Implementing Classes:
MersenneTwister, MersenneTwister64, UniversalGenerator

public interface RandomNumberGenerator
Random number generator interface.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    next(int numbits)
    Returns up to 32 random bits.
    double
    Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.
    void
    nextDoubles(double[] d)
    Returns a vector of pseudorandom, uniformly distributed double values between 0.0 and 1.0 from this random number generator's sequence.
    int
    Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.
    int
    nextInt(int n)
    Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
    long
    Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence.
    void
    setSeed(long seed)
    Initialize the random generator with a seed.
  • Method Details

    • setSeed

      void setSeed(long seed)
      Initialize the random generator with a seed.
      Parameters:
      seed - the seed of random numbers.
    • next

      int next(int numbits)
      Returns up to 32 random bits.
      Parameters:
      numbits - the number of random bits to generate.
      Returns:
      random bits.
    • nextInt

      int nextInt()
      Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.
      Returns:
      random number.
    • nextInt

      int nextInt(int n)
      Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
      Parameters:
      n - the upper bound of random number (exclusive).
      Returns:
      random number.
    • nextLong

      long nextLong()
      Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence.
      Returns:
      random number.
    • nextDouble

      double nextDouble()
      Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.
      Returns:
      random number.
    • nextDoubles

      void nextDoubles(double[] d)
      Returns a vector of pseudorandom, uniformly distributed double values between 0.0 and 1.0 from this random number generator's sequence.
      Parameters:
      d - the output random numbers.