DoubleRandomEngine
cern.jet.random.tdouble.engine

Class DoubleRandomEngine

  • All Implemented Interfaces:
    DoubleFunction, IntFunction, LongFunction, Serializable, Cloneable
    Direct Known Subclasses:
    DoubleMersenneTwister, DRand


    public abstract class DoubleRandomEngineextends PersistentObjectimplements DoubleFunction, IntFunction, LongFunction
    Abstract base class for uniform pseudo-random number generating engines.

    Most probability distributions are obtained by using a uniform pseudo-random number generation engine followed by a transformation to the desired distribution. Thus, subclasses of this class are at the core of computational statistics, simulations, Monte Carlo methods, etc.

    Subclasses produce uniformly distributed int's and long's in the closed intervals [Integer.MIN_VALUE,Integer.MAX_VALUE] and [Long.MIN_VALUE,Long.MAX_VALUE], respectively, as well as float's and double's in the open unit intervals (0.0f,1.0f) and (0.0,1.0), respectively.

    Subclasses need to override one single method only: nextInt(). All other methods generating different data types or ranges are usually layered upon nextInt(). long's are formed by concatenating two 32 bit int's. float's are formed by dividing the interval [0.0f,1.0f] into 232 sub intervals, then randomly choosing one subinterval. double's are formed by dividing the interval [0.0,1.0] into 264 sub intervals, then randomly choosing one subinterval.

    Note that this implementation is not synchronized.

    See Also:
    DoubleMersenneTwister, MersenneTwister64, Random, Serialized Form
    • Method Summary

      Methods 
      Modifier and TypeMethod and Description
      doubleapply(double dummy)
      Equivalent to raw().
      intapply(int dummy)
      Equivalent to nextInt().
      longapply(long dummy)
      Equivalent to nextLong().
      static DoubleRandomEnginemakeDefault()
      Constructs and returns a new uniform random number engine seeded with the current time.
      doublenextDouble()
      Returns a 64 bit uniformly distributed random number in the open unit interval (0.0,1.0) (excluding 0.0 and 1.0).
      floatnextFloat()
      Returns a 32 bit uniformly distributed random number in the open unit interval (0.0f,1.0f) (excluding 0.0f and 1.0f).
      abstract intnextInt()
      Returns a 32 bit uniformly distributed random number in the closed interval [Integer.MIN_VALUE,Integer.MAX_VALUE] (including Integer.MIN_VALUE and Integer.MAX_VALUE);
      longnextLong()
      Returns a 64 bit uniformly distributed random number in the closed interval [Long.MIN_VALUE,Long.MAX_VALUE] (including Long.MIN_VALUE and Long.MAX_VALUE).
      doubleraw()
      Returns a 32 bit uniformly distributed random number in the open unit interval (0.0,1.0) (excluding 0.0 and 1.0).
    • Method Detail

      • apply

        public double apply(double dummy)
        Equivalent to raw(). This has the effect that random engines can now be used as function objects, returning a random number upon function evaluation.
        Specified by:
        apply in interface DoubleFunction
        Parameters:
        dummy - argument passed to the function.
        Returns:
        the result of the function.
      • apply

        public int apply(int dummy)
        Equivalent to nextInt(). This has the effect that random engines can now be used as function objects, returning a random number upon function evaluation.
        Specified by:
        apply in interface IntFunction
        Parameters:
        dummy - argument passed to the function.
        Returns:
        the result of the function.
      • apply

        public long apply(long dummy)
        Equivalent to nextLong(). This has the effect that random engines can now be used as function objects, returning a random number upon function evaluation.
        Specified by:
        apply in interface LongFunction
        Parameters:
        dummy - argument passed to the function.
        Returns:
        the result of the function.
      • nextDouble

        public double nextDouble()
        Returns a 64 bit uniformly distributed random number in the open unit interval (0.0,1.0) (excluding 0.0 and 1.0).
      • nextFloat

        public float nextFloat()
        Returns a 32 bit uniformly distributed random number in the open unit interval (0.0f,1.0f) (excluding 0.0f and 1.0f).
      • nextInt

        public abstract int nextInt()
        Returns a 32 bit uniformly distributed random number in the closed interval [Integer.MIN_VALUE,Integer.MAX_VALUE] (including Integer.MIN_VALUE and Integer.MAX_VALUE);
      • nextLong

        public long nextLong()
        Returns a 64 bit uniformly distributed random number in the closed interval [Long.MIN_VALUE,Long.MAX_VALUE] (including Long.MIN_VALUE and Long.MAX_VALUE).
      • raw

        public double raw()
        Returns a 32 bit uniformly distributed random number in the open unit interval (0.0,1.0) (excluding 0.0 and 1.0).

SCaVis 2.1 © jWork.ORG