corejava
Class RandomIntGenerator

java.lang.Object
  |
  +--corejava.RandomIntGenerator

public class RandomIntGenerator
extends java.lang.Object

An improved random number generator based on Algorithm B in Knuth Vol 2 p32. Gives a set of random integers that does not exhibit as much correlation as the method used by the Java random number generator.


Constructor Summary
RandomIntGenerator(int l, int h)
          Constructs an object that generates random integers in a given range
 
Method Summary
 int draw()
          Generates a random integer in a range of integers
static void main(java.lang.String[] args)
          test stub for the class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomIntGenerator

public RandomIntGenerator(int l,
                          int h)
Constructs an object that generates random integers in a given range
Parameters:
l - the lowest integer in the range
h - the highest integer in the range
Method Detail

draw

public int draw()
Generates a random integer in a range of integers
Returns:
a random integer

main

public static void main(java.lang.String[] args)
test stub for the class