Documentation of 'Catalano.Math.Random.Pcg32' Java class
Pcg32
Catalano.Math.Random

Class Pcg32

  • All Implemented Interfaces:
    IRandomNumberGenerator


    public class Pcg32
    extends java.lang.Object
    implements IRandomNumberGenerator
    An instance of this class is used to generate a stream of pseudorandom numbers, similarly to Random.

    The main differences are:

    • Constructor Summary

      Constructors 
      Constructor and Description
      Pcg32()
      Creates a new random number generator using current time (returned by System.nanoTime()) as the seed and a unique stream number.
      Pcg32(long initState, long initSeq)
      Creates a new random number generator using a long seed and a long stream number.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int nextBits(int bits)
      Returns up to 32 random bits.
      boolean nextBoolean()
      Returns the next pseudorandom, approximately uniformly distributed boolean value.
      double nextDouble()
      Returns the next pseudorandom, approximately uniformly distributed double value between 0.0 (inclusive) and 1.0 (exclusive).
      double nextDouble(double bound)
      Returns the next pseudorandom, approximately uniformly distributed double value between 0.0 (inclusive) and bound (exclusive).
      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.
      float nextFloat()
      Returns the next pseudorandom, approximately uniformly distributed float value between 0.0 (inclusive) and 1.0 (exclusive).
      float nextFloat(float bound)
      Returns the next pseudorandom, approximately uniformly distributed float value between 0.0 (inclusive) and bound (exclusive).
      double nextGaussian()
      Returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.
      double nextGaussian(double mean, double standardDeviation)
      Returns the next pseudorandom, Gaussian ("normally") distributed double value with given mean and standard deviation from this random number generator's sequence.
      int nextInt()
      Returns the next pseudorandom, approximately uniformly distributed int value from this random number generator's sequence.
      int nextInt(int n)
      Returns the next pseudorandom, approximately uniformly distributed int value between 0 (inclusive) and n (exclusive).
      long nextLong()
      Returns the next pseudorandom, approximately uniformly distributed long value from this random number generator's sequence.
      long nextLong(long n)
      Returns the next pseudorandom, approximately uniformly distributed long value between 0 (inclusive) and n (exclusive).
      void seed()
      Initializes the generator with current time as the state and a (very likely to be) unique stream number.
      void seed(long initState, long initSeq) 
      void setSeed(long seed)
      Set seed.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Pcg32

        public Pcg32(long initState,
                     long initSeq)
        Creates a new random number generator using a long seed and a long stream number.

        The invocation new Pcg32(initState, initSeq) is equivalent to:

         
         Pcg32 rnd = new Pcg32();
         rnd.seed(initState, initSeq);
         
        See Also:
        seed(long, long)
      • Pcg32

        public Pcg32()
        Creates a new random number generator using current time (returned by System.nanoTime()) as the seed and a unique stream number.
        See Also:
        seed()
    • Method Detail

      • nextInt

        public int nextInt()
        Returns the next pseudorandom, approximately uniformly distributed int value from this random number generator's sequence. The general contract of nextInt is that one int value is pseudorandomly generated and returned. All 232 possible int values are produced with (approximately) equal probability.
        Specified by:
        nextInt in interface IRandomNumberGenerator
        See Also:
        Random.nextInt()
      • nextInt

        public int nextInt(int n)
        Returns the next pseudorandom, approximately uniformly distributed int value between 0 (inclusive) and n (exclusive).
        Specified by:
        nextInt in interface IRandomNumberGenerator
        See Also:
        Random.nextInt(int)
      • nextLong

        public long nextLong()
        Returns the next pseudorandom, approximately uniformly distributed long value from this random number generator's sequence. The general contract of nextLong is that one long value is pseudorandomly generated and returned. All 264 possible long values are produced with (approximately) equal probability.
        Specified by:
        nextLong in interface IRandomNumberGenerator
        See Also:
        Random.nextLong()
      • nextLong

        public long nextLong(long n)
        Returns the next pseudorandom, approximately uniformly distributed long value between 0 (inclusive) and n (exclusive).
        Returns:
      • nextBoolean

        public boolean nextBoolean()
        Returns the next pseudorandom, approximately uniformly distributed boolean value.
        See Also:
        Random.nextBoolean()
      • nextFloat

        public float nextFloat()
        Returns the next pseudorandom, approximately uniformly distributed float value between 0.0 (inclusive) and 1.0 (exclusive).
        See Also:
        Random.nextFloat()
      • nextFloat

        public float nextFloat(float bound)
        Returns the next pseudorandom, approximately uniformly distributed float value between 0.0 (inclusive) and bound (exclusive).
      • nextDouble

        public double nextDouble()
        Returns the next pseudorandom, approximately uniformly distributed double value between 0.0 (inclusive) and 1.0 (exclusive).
        Specified by:
        nextDouble in interface IRandomNumberGenerator
        See Also:
        Random.nextDouble()
      • nextDouble

        public double nextDouble(double bound)
        Returns the next pseudorandom, approximately uniformly distributed double value between 0.0 (inclusive) and bound (exclusive).
      • nextGaussian

        public double nextGaussian()
        Returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.
        See Also:
        Random.nextGaussian()
      • nextGaussian

        public double nextGaussian(double mean,
                                   double standardDeviation)
        Returns the next pseudorandom, Gaussian ("normally") distributed double value with given mean and standard deviation from this random number generator's sequence.
      • seed

        public void seed(long initState,
                         long initSeq)
      • seed

        public void seed()
        Initializes the generator with current time as the state and a (very likely to be) unique stream number. This ensures that even if multiple generators are initialized using this method while System.nanoTime() returns the same time, they will have different sequences.
      • nextDoubles

        public void nextDoubles(double[] d)
        Description copied from interface: IRandomNumberGenerator
        Returns a vector of pseudorandom, uniformly distributed double values between 0.0 and 1.0 from this random number generator's sequence.
        Specified by:
        nextDoubles in interface IRandomNumberGenerator

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.