All Packages Class Hierarchy This Package Previous Next Index
Class jnt.random.LongUniformSequence
java.lang.Object
|
+----jnt.random.LongUniformSequence
- public class LongUniformSequence
- 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 similar to UniformSequence, except that computations are
done internally with long integers. This yields sequences with much longer
cycles, but roughly doubles the computation time to generate each random
variate.
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;
LongUniformSequence random;
random = new LongUniformSequence( 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:
- UniformSequence
-
LongUniformSequence()
- Initializes a sequence of uniformly distributed quasi random numbers with a
seed based on the system clock.
-
LongUniformSequence(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.
-
LongUniformSequence(long)
- Initializes a sequence of uniformly distributed quasi random numbers with a
given seed.
-
LongUniformSequence(long, double, double)
- Initializes a sequence of uniformly distributed quasi random numbers
with a given seed on a given half-open interval [left,right).
-
next()
- Returns the next random number in the sequence.
LongUniformSequence
public LongUniformSequence()
- Initializes a sequence of uniformly distributed quasi random numbers with a
seed based on the system clock.
LongUniformSequence
public LongUniformSequence(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).
LongUniformSequence
public LongUniformSequence(long seed)
- Initializes a sequence of uniformly distributed quasi random numbers with a
given seed.
- Parameters:
- seed - (long)
The seed of the random number generator. Two sequences with the same
seed will be identical.
LongUniformSequence
public LongUniformSequence(long 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 - (long)
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).
next
public double next()
- Returns the next random number in the sequence.
All Packages Class Hierarchy This Package Previous Next Index