All Packages Class Hierarchy This Package Previous Next Index
Class jnt.random.LongNormalSequence
java.lang.Object
|
+----jnt.random.LongNormalSequence
- public class LongNormalSequence
- extends Object
Provides a sequence of normally distributed quasi random numbers.
By default the numbers are drawn from a distribution with mean 0 and
standard deviation 1. The mean and standard deviation 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 NormalSequence, except that computations are
done internally with long integers. This yields sequences with much longer
cycles, but can increase the computation time to generate each random
variate by a factor of 10.
This class is a translation of the Fortran subroutine RNOR from the NBS
Core Math Library. RNOR was written by David Kahanaer and George
Marsaglia.
- Example of use:
-
Print 20 random numbers normally distributed with mean 0 and standard
deviation 2.
int i;
long seed = 687346;
double mean = 0.0, stddev = 2.0;
LongNormalSequence random;
random = new LongNormalSequence( seed, mean, stddev );
for (i=0, i<20, i++) System.out.println( random.next() );
References:
- Marsaglia and Tsang, "A Fast, Easily Implemented Method For Sampling From
Decreasing Or Symmetric Unimodal Density Functions", SIAM Journal of
Scientific and Statistical Computing, 1983.
- Version:
- 23 October 1997
- Author:
- Ronald F. Boisvert, NIST
- See Also:
- NormalSequence
-
LongNormalSequence()
- Initializes a sequence of normally distributed quasi random numbers with
mean 0 and standard deviation 1 using a seed based on the system clock.
-
LongNormalSequence(double, double)
- Initializes a sequence of normally distributed quasi random numbers with
given mean and standard deviation using a seed based on the system clock
-
LongNormalSequence(long)
- Initializes a sequence of normally distributed quasi random numbers with
mean 0 and standard deviation 1 using a given seed.
-
LongNormalSequence(long, double, double)
- Initializes a sequence of normally distributed quasi random numbers with
given mean, standard deviation and seed.
-
next()
- Returns the next random number in the sequence.
LongNormalSequence
public LongNormalSequence()
- Initializes a sequence of normally distributed quasi random numbers with
mean 0 and standard deviation 1 using a seed based on the system clock.
LongNormalSequence
public LongNormalSequence(double mean,
double stddev)
- Initializes a sequence of normally distributed quasi random numbers with
given mean and standard deviation using a seed based on the system clock
- Parameters:
- mean - (double)
The mean of the normal distribution from which the random numbers
are drawn.
- stddev - (double)
The standard deviation of the normal distribution from which the random
numbers are drawn.
LongNormalSequence
public LongNormalSequence(long seed)
- Initializes a sequence of normally distributed quasi random numbers with
mean 0 and standard deviation 1 using a given seed.
- Parameters:
- seed - (long)
The seed of the random number generator. Two sequences with the same
seed will be identical.
LongNormalSequence
public LongNormalSequence(long seed,
double mean,
double stddev)
- Initializes a sequence of normally distributed quasi random numbers with
given mean, standard deviation and seed.
- Parameters:
- seed - (long)
The seed of the random number generator. Two sequences with the same
seed will be identical.
- mean - (double)
The mean of the normal distribution from which the random numbers
are drawn.
- stddev - (double)
The standard deviation of the normal distribution from which the random
numbers are drawn.
next
public double next()
- Returns the next random number in the sequence.
All Packages Class Hierarchy This Package Previous Next Index