Module m3DCS

Class RandomGenerator

java.lang.Object
de.grogra.blocks.arrangeBlock.RandomGenerator
All Implemented Interfaces:
ContinuousGenerator, Seedable

public class RandomGenerator extends Object implements ContinuousGenerator
A random number generator producing pseudorandom numbers based on the value of a specific seed. The generator is a multiplicative linear congruential generator. It generates numbers through the following structure:

Y[1] = (742938285*Y[0]) mod (231-1)

The seed (Y[0]) provided is used to generate a sequence of pseudorandom numbers uniformly distributed between 0 and 1. The cycle of the generator is 231-2.

Version:
1.0, 2 October 2002
Author:
F.Mallet from Costas Simatos original
  • Constructor Details

    • RandomGenerator

      public RandomGenerator()
    • RandomGenerator

      public RandomGenerator(long seed)
  • Method Details

    • sample

      public double sample()
      Specified by:
      sample in interface ContinuousGenerator
    • nextLong

      public long nextLong()
      Returns:
      The next long random number in the sequence
    • setSeed

      public void setSeed(long seed)
      Description copied from interface: Seedable
      Set the random number generator's seed.
      Specified by:
      setSeed in interface Seedable
      Parameters:
      seed - The new seed for the generator
    • getSeed

      public long getSeed()
      Description copied from interface: Seedable
      Get the random number generator's seed.
      Specified by:
      getSeed in interface Seedable
      Returns:
      The generator's seed
    • reseed

      public void reseed()
      Description copied from interface: Seedable
      Get another seed well-spaced (from the default SeedGenerator)
      Specified by:
      reseed in interface Seedable