All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jnt.random.UniformSequence

java.lang.Object
   |
   +----jnt.random.UniformSequence

public class UniformSequence
extends Object
Provides a sequence of uniformly distributed quasi random numbers.

By default the numbers are drawn from the interval [0,1). The interval can be changed using the constructor. The user may also specify an integer seed for the sequence; sequences with the same seed are identical. If no seed is specified by the user, then a seed based on the system clock is used, which should provide a new sequence on subsequent constructions. (Beware: two sequences constructed within the clock resolution -- a millisecond -- could be identical, and so providing your own seed is generally preferable.)

This class is a translation of the Fortran subroutine UNI from the NBS Core Math Library. UNI was written by James Blue, David Kahanaer and George Marsaglia.

This generator is of the lagged Fibbonacci type.

Example of use:
Print 20 random numbers on [-1,1).

int i, seed = 687346;
double left = -1.0, right = 1.0;
UniformSequence random; 
random = new UniformSequence( seed, left, right );
for (i=0, i<20, i++) System.out.println( random.next() );

Version:
3 December 1997
Author:
Ronald F. Boisvert, NIST
See Also:
LongUniformSequence

Constructor Index

 o UniformSequence()
Initializes a sequence of uniformly distributed quasi random numbers with a seed based on the system clock.
 o UniformSequence(double, double)
Initializes a sequence of uniformly distributed quasi random numbers on a given half-open interval [left,right) with a seed based on the system clock.
 o UniformSequence(int)
Initializes a sequence of uniformly distributed quasi random numbers with a given seed.
 o UniformSequence(int, double, double)
Initializes a sequence of uniformly distributed quasi random numbers with a given seed on a given half-open interval [left,right).

Method Index

 o next()
Returns the next random number in the sequence.

Constructors

 o UniformSequence
 public UniformSequence()
Initializes a sequence of uniformly distributed quasi random numbers with a seed based on the system clock.

 o UniformSequence
 public UniformSequence(double left,
                        double right)
Initializes a sequence of uniformly distributed quasi random numbers on a given half-open interval [left,right) with a seed based on the system clock.

Parameters:
left - (double)
The left endpoint of the half-open interval [left,right).
right - (double)
The right endpoint of the half-open interval [left,right).
 o UniformSequence
 public UniformSequence(int seed)
Initializes a sequence of uniformly distributed quasi random numbers with a given seed.

Parameters:
seed - (int)
The seed of the random number generator. Two sequences with the same seed will be identical.
 o UniformSequence
 public UniformSequence(int seed,
                        double left,
                        double right)
Initializes a sequence of uniformly distributed quasi random numbers with a given seed on a given half-open interval [left,right).

Parameters:
seed - (int)
The seed of the random number generator. Two sequences with the same seed will be identical.
left - (double)
The left endpoint of the half-open interval [left,right).
right - (double)
The right endpoint of the half-open interval [left,right).

Methods

 o next
 public double next()
Returns the next random number in the sequence.


All Packages  Class Hierarchy  This Package  Previous  Next  Index