|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.numericalmethod.suanshu.stats.random.RNG
public class RNG
This is the global pseudo-random number generator for the SuanShu library. All built-in random number and distribution generators call this class.
The following code always return the same instance of the global pseudo-random number generator. No new instance is created.
RandomNumberGenerator rng = new RNG();
Seeding this RNG seeds the whole library.
| Constructor Summary | |
|---|---|
RNG()
|
|
| Method Summary | |
|---|---|
double |
nextDouble()
Get a double between 0 and 1. |
long |
nextLong()
Get the next random long. |
static double |
random()
Get a double between 0 and 1. |
void |
seed(long... seeds)
Seed the global pseudo-random number generator. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RNG()
| Method Detail |
|---|
public static double random()
double between 0 and 1.
Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range.
double between 0 and 1public void seed(long... seeds)
Although seeds is a long array, we use only the first element,
namely, seeds[0].
seed in interface RandomNumberGeneratorseeds - the seedpublic double nextDouble()
This is the same as calling
double u = RNG.random();
In other words, the following code gives a reference to the same global random number generator.
RandomNumberGenerator rng = new RNG();
nextDouble in interface RandomNumberGeneratorpublic long nextLong()
RandomLongGeneratorlong.
nextLong in interface RandomLongGeneratorlong
|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||