All Packages Class Hierarchy This Package Previous Next Index
Class jnt.random.NormalSequence
java.lang.Object

+jnt.random.NormalSequence
 public class NormalSequence
 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 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, seed = 687346;
double mean = 0.0, stddev = 2.0;
NormalSequence random;
random = new NormalSequence( 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:
 LongNormalSequence

NormalSequence()
 Initializes a sequence of normally distributed quasi random numbers with
mean 0 and standard deviation 1 using a seed based on the system clock.

NormalSequence(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

NormalSequence(int)
 Initializes a sequence of normally distributed quasi random numbers with
mean 0 and standard deviation 1 using a given seed.

NormalSequence(int, 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.
NormalSequence
public NormalSequence()
 Initializes a sequence of normally distributed quasi random numbers with
mean 0 and standard deviation 1 using a seed based on the system clock.
NormalSequence
public NormalSequence(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.
NormalSequence
public NormalSequence(int seed)
 Initializes a sequence of normally distributed quasi random numbers with
mean 0 and standard deviation 1 using a given seed.
 Parameters:
 seed  (int)
The seed of the random number generator. Two sequences with the same
seed will be identical.
NormalSequence
public NormalSequence(int seed,
double mean,
double stddev)
 Initializes a sequence of normally distributed quasi random numbers with
given mean, standard deviation and seed.
 Parameters:
 seed  (int)
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