public class UniformRNG extends Object implements RandomLongGenerator
Set a seed before drawing values. Reproducibility requires the same algorithm, seed, and sequence of calls. Drawing advances generator state; use independent generators for independent streams. These generators are for numerical simulation, not cryptographic key generation.
import dev.nm.stat.random.rng.univariate.uniform.UniformRNG;
UniformRNG first = new UniformRNG(UniformRNG.Method.MERSENNE_TWISTER);
UniformRNG second = new UniformRNG(UniformRNG.Method.MERSENNE_TWISTER);
first.seed(12345L);
second.seed(12345L);
for (int i = 0; i < 5; ++i) {
assert first.nextDouble() == second.nextDouble();
}
| Modifier and Type | Class and Description |
|---|---|
static class |
UniformRNG.Method
the pseudo uniform random number generators available
|
| Constructor and Description |
|---|
UniformRNG()
Construct a pseudo uniform random number generator.
|
UniformRNG(long... seeds)
Construct a seeded pseudo uniform random number generator.
|
UniformRNG(UniformRNG.Method method)
Construct a pseudo uniform random number generator.
|
| Modifier and Type | Method and Description |
|---|---|
double |
nextDouble()
Get the next random
double. |
long |
nextLong()
Get the next random
long. |
void |
seed(long... seeds)
Seed the random number/vector/scenario generator to produce repeatable experiments.
|
public UniformRNG(UniformRNG.Method method)
method - the uniform random number generation algorithm to usepublic UniformRNG()
public UniformRNG(long... seeds)
seeds - the seed(s)public void seed(long... seeds)
Seedablepublic double nextDouble()
RandomNumberGeneratordouble.nextDouble in interface RandomNumberGeneratorpublic long nextLong()
RandomLongGeneratorlong.nextLong in interface RandomLongGeneratorlongCopyright © 2010-2026 NM Group. All Rights Reserved.