Package edu.rit.util

Class Mcg1Random

java.lang.Object
edu.rit.util.Random
edu.rit.util.Mcg1Random
All Implemented Interfaces:
Serializable

public class Mcg1Random extends Random
Class Mcg1Random provides a default pseudorandom number generator (PRNG) designed for use in parallel scientific programming. To create an instance of class Mcg1Random, either use the Mcg1Random() constructor, or use the static getInstance(long,String) method in class Random.

Class Mcg1Random uses L'Ecuyer's 63-bit multiplicative congruential generator:

     seed := seed * A (mod M);
 
with A = 2307085864 and M = 263-25. For further information, see P. L'Ecuyer, F. Blouin, and R. Couture, A search for good multiple recursive random number generators, ACM Transactions on Modeling and Computer Simulation, 3(2):87-98, April 1993.
Version:
01-Mar-2008
Author:
Alan Kaminsky
See Also:
  • Constructor Details

    • Mcg1Random

      public Mcg1Random(long seed)
      Construct a new PRNG with the given seed. The seed must not be 0.
      Parameters:
      seed - Seed.
      Throws:
      IllegalArgumentException - (unchecked exception) Thrown if seed = 0.
  • Method Details

    • setSeed

      public void setSeed(long seed)
      Set this PRNG's seed.

      Note: Depending on the PRNG algorithm, certain seed values may not be allowed. See the PRNG algorithm subclass for further information. Set this PRNG's seed. The seed must not be 0.

      Specified by:
      setSeed in class Random
      Parameters:
      seed - Seed.
      Throws:
      IllegalArgumentException - (unchecked exception) Thrown if seed = 0.
    • next

      protected long next()
      Return the next 64-bit pseudorandom value in this PRNG's sequence.
      Specified by:
      next in class Random
      Returns:
      Pseudorandom value.
    • next

      protected long next(long skip)
      Return the 64-bit pseudorandom value the given number of positions ahead in this PRNG's sequence. Return the 64-bit pseudorandom value the given number of positions ahead in this PRNG's sequence.
      Specified by:
      next in class Random
      Parameters:
      skip - Number of positions to skip, assumed to be > 0.
      Returns:
      Pseudorandom value.