|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.jagrlib.RandomJames
public class RandomJames
Random number generator by F. James adopted by Phil Linttell, James F. Hickling & Josef Pelikan.
This random number generator originally appeared in "Toward a Universal Random Number Generator" by George Marsaglia and Arif Zaman. Florida State University Report: FSU-SCRI-87-50 (1987)
It was later modified by F. James and published in "A Review of Pseudo-random Number Generators"
Converted from FORTRAN to C by Phil Linttell, James F. Hickling Management Consultants Ltd, Aug. 14, 1989.
THIS IS THE BEST KNOWN RANDOM NUMBER GENERATOR AVAILABLE. (However, a newly discovered technique can yield a period of 10^600. But that is still in the development stage.)
It passes ALL of the tests for random number generators and has a period of 2^144, is completely portable (gives bit identical results on all machines with at least 24-bit mantissas in the floating point representation).
The algorithm is a combination of a Fibonacci sequence (with lags of 97 and 33, and operation "subtraction plus one, modulo one") and an "arithmetic sequence" (using subtraction).
On a Vax 11/780, this random number generator can produce a number in 13 microseconds.
Field Summary | |
---|---|
protected double |
c
|
protected double |
cd
|
protected double |
cm
|
protected int |
i97
|
protected int |
j97
|
protected double |
norAdd
|
protected double |
norMul
|
boolean |
ok
Success flag. |
protected int[] |
perm
|
protected int |
permPtr
|
protected int |
permSize
|
protected double |
prepMean
|
protected int |
prepRep
|
protected double |
prepVar
|
protected double[] |
u
|
Constructor Summary | |
---|---|
RandomJames()
Default constructor ( ij = 1802, kl = 9373 ). |
|
RandomJames(int ij,
int kl)
Initializing constructor. |
Method Summary | |
---|---|
protected void |
checkNormal(double mean,
double variance,
int rep)
Pseudo-normal distribution parameter setup. |
double |
normalNumber(double mean,
double variance,
int rep)
Pseudo-normal (Gaussian) distribution generator. |
void |
normalNumbers(double mean,
double variance,
int rep,
double[] vec)
Pseudo-normal (Gaussian) distribution generator. |
void |
normalNumbers(double mean,
double variance,
int rep,
double[] vec,
int from,
int number)
Pseudo-normal (Gaussian) distribution generator. |
int |
permutationFirst(int size)
Random permutation setup. |
int |
permutationNext()
Computes next permutation item. |
double |
randomDouble(double min,
double max)
Generates random double number from the given range. |
float |
randomFloat(float min,
float max)
Generates random float number from the given range. |
int |
randomInteger(int min,
int max)
Generates random integer number from the given range. |
void |
randomize()
Undeterministic restart of a sequence (uses system time). |
double[] |
randomPointFromTriangle(double[] a,
double[] b,
double[] c,
double[] result)
Generates random point in the given triangle. |
void |
reset(int ij,
int kl)
Deterministic restart of a sequence. |
double[] |
uniformDirection(double minLat,
double maxLat,
double[] result)
Uniformly generates random unit vector from the given latitude-defined strip. |
double |
uniformNumber()
Uniform random number generator from [0,1]. |
void |
uniformNumbers(double[] vec)
Vector of uniform random numbers (from [0,1]). |
void |
uniformNumbers(double[] vec,
int from,
int number)
Vector of uniform random numbers (from [0,1]). |
boolean |
validate()
Validation test of a generator algorithm. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected double[] u
protected double c
protected double cd
protected double cm
protected int i97
protected int j97
protected double prepMean
protected double prepVar
protected double norMul
protected double norAdd
protected int prepRep
protected int[] perm
protected int permPtr
protected int permSize
public boolean ok
Constructor Detail |
---|
public RandomJames(int ij, int kl)
public RandomJames()
Method Detail |
---|
protected void checkNormal(double mean, double variance, int rep)
public void reset(int ij, int kl)
ij
- Random seed #1 [0,31328]kl
- Random seed #2 [0,30081]public void randomize()
public boolean validate()
public double uniformNumber()
public void uniformNumbers(double[] vec)
public void uniformNumbers(double[] vec, int from, int number)
public double normalNumber(double mean, double variance, int rep)
public void normalNumbers(double mean, double variance, int rep, double[] vec)
public void normalNumbers(double mean, double variance, int rep, double[] vec, int from, int number)
public int permutationFirst(int size)
size
- Permutation size.
0
to size - 1
).permutationNext()
public int permutationNext()
-1
at the end.permutationFirst(int)
public final int randomInteger(int min, int max)
public final double randomDouble(double min, double max)
public final float randomFloat(float min, float max)
public final double[] randomPointFromTriangle(double[] a, double[] b, double[] c, double[] result)
a
- Triangle vertex A.b
- Triangle vertex B.c
- Triangle vertex C.result
- Pre-allocated result array (can be null
).
null
in case of failure.public final double[] uniformDirection(double minLat, double maxLat, double[] result)
uniformDirection( -1.0, 1.0, result )
,
for direction from the upper hemisphere, use uniformDirection( 0.0, 1.0, result )
.
minLat
- Sine of the minimum latitude.maxLat
- Sine of the maximum latitude.result
- Pre-allocated result array (can be null
).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |