AntitheticStream
umontreal.iro.lecuyer.rng

Class AntitheticStream

  • All Implemented Interfaces:
    RandomStream


    public class AntitheticStreamextends Objectimplements RandomStream
    This container class allows the user to force any RandomStream to return antithetic variates. That is, nextDouble returns 1 - u instead of u and the corresponding change is made in nextInt. Any instance of this class behaves exactly like a RandomStream, except that it depends on another random number generator stream, called the base stream, to generate its numbers. Any call to one of the next... methods of this class will modify the state of the base stream.
    • Constructor Summary

      Constructors 
      Constructor and Description
      AntitheticStream(RandomStream stream)
      Constructs a new antithetic stream, using the random numbers from the base stream stream.
    • Method Summary

      Methods 
      Modifier and TypeMethod and Description
      voidnextArrayOfDouble(double[] u, int start, int n)
      Calls nextArrayOfDouble (u, start, n) for the base stream, then replaces each u[i] by 1.0 - u[i].
      voidnextArrayOfInt(int i, int j, int[] u, int start, int n)
      Calls nextArrayOfInt (i, j, u, start, n) for the base stream, then replaces each u[i] by j - i - u[i].
      doublenextDouble()
      Returns 1.0 - s.nextDouble() where s is the base stream.
      intnextInt(int i, int j)
      Returns j - i - s.nextInt(i, j) where s is the base stream.
      voidresetNextSubstream()
      Reinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.
      voidresetStartStream()
      Reinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.
      voidresetStartSubstream()
      Reinitializes the stream to the beginning of its current substream: Cg is set to Bg.
      StringtoString()
      Returns a string starting with "Antithetic of " and finishing with the result of the call to the toString method of the generator.
    • Constructor Detail

      • AntitheticStream

        public AntitheticStream(RandomStream stream)
        Constructs a new antithetic stream, using the random numbers from the base stream stream.
    • Method Detail

      • resetStartStream

        public void resetStartStream()
        Description copied from interface: RandomStream
        Reinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.
        Specified by:
        resetStartStream in interface RandomStream
      • resetStartSubstream

        public void resetStartSubstream()
        Description copied from interface: RandomStream
        Reinitializes the stream to the beginning of its current substream: Cg is set to Bg.
        Specified by:
        resetStartSubstream in interface RandomStream
      • resetNextSubstream

        public void resetNextSubstream()
        Description copied from interface: RandomStream
        Reinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.
        Specified by:
        resetNextSubstream in interface RandomStream
      • toString

        public String toString()
        Returns a string starting with "Antithetic of " and finishing with the result of the call to the toString method of the generator.
        Specified by:
        toString in interface RandomStream
        Overrides:
        toString in class Object
        Returns:
        the state of the generator formated as a string
      • nextDouble

        public double nextDouble()
        Returns 1.0 - s.nextDouble() where s is the base stream.
        Specified by:
        nextDouble in interface RandomStream
        Returns:
        the next generated uniform
      • nextInt

        public int nextInt(int i,          int j)
        Returns j - i - s.nextInt(i, j) where s is the base stream.
        Specified by:
        nextInt in interface RandomStream
        Parameters:
        i - smallest integer that can be generated
        j - greatest integer that can be generated
        Returns:
        the generated integer
      • nextArrayOfDouble

        public void nextArrayOfDouble(double[] u,                     int start,                     int n)
        Calls nextArrayOfDouble (u, start, n) for the base stream, then replaces each u[i] by 1.0 - u[i].
        Specified by:
        nextArrayOfDouble in interface RandomStream
        Parameters:
        u - the array in which the numbers will be stored
        start - the first index of u to be used
        n - the number of random numbers to put in u
      • nextArrayOfInt

        public void nextArrayOfInt(int i,                  int j,                  int[] u,                  int start,                  int n)
        Calls nextArrayOfInt (i, j, u, start, n) for the base stream, then replaces each u[i] by j - i - u[i].
        Specified by:
        nextArrayOfInt in interface RandomStream
        Parameters:
        i - the smallest possible integer to put in u
        j - the largest possible integer to put in u
        u - the array in which the numbers will be stored
        start - the first index of u to be used
        n - the number of random numbers to put in u

SCaVis 2.0 © jWork.ORG