Class JDKThreadLocalRandomGenerator
- All Implemented Interfaces:
org.apache.commons.math3.random.RandomGenerator
RandomGenerator
that internally uses the ThreadLocalRandom
,
a very fast Pseudo-Random Number Generator (PRNG)
with higher performance than Random
, mainly in concurrent environments.
The ThreadLocalRandom
also has
much better performance than PRNGs available in org.apache.commons.math3
,
despite it probably has worse statistical properties.
This generator has some drawbacks.
It only generates the seed internally and doesn't allow setting an explicit seed.
Calling the setSeed()
methods will throw an UnsupportedOperationException
and there is no way to get the generated seed.
This later issue makes it impossible to reproduce a
simulation experiment to verify the generated results if the seed is unknown.
Finally, it doesn't allow applying the
Antithetic Variates Technique
in order to try reducing variance of experiments using the generated numbers.
Classes such as UniformDistr
provide such a feature if the
underlying PRNG allows setting a seed.
That is explained because the technique is applied when multiple runs of the same simulation
are executed.
In such scenario, the second half of experiments have to use the seeds from the first half.
- Since:
- CloudSim Plus 4.3.9
- Author:
- Manoel Campos da Silva Filho
-
Method Details
-
getInstance
-
setSeed
public void setSeed(int seed) - Specified by:
setSeed
in interfaceorg.apache.commons.math3.random.RandomGenerator
-
setSeed
public void setSeed(int[] seed) - Specified by:
setSeed
in interfaceorg.apache.commons.math3.random.RandomGenerator
-
setSeed
public void setSeed(long seed) - Specified by:
setSeed
in interfaceorg.apache.commons.math3.random.RandomGenerator
-
nextBytes
public void nextBytes(byte[] bytes) - Specified by:
nextBytes
in interfaceorg.apache.commons.math3.random.RandomGenerator
-
nextInt
public int nextInt()- Specified by:
nextInt
in interfaceorg.apache.commons.math3.random.RandomGenerator
-
nextInt
public int nextInt(int bound) - Specified by:
nextInt
in interfaceorg.apache.commons.math3.random.RandomGenerator
-
nextLong
public long nextLong()- Specified by:
nextLong
in interfaceorg.apache.commons.math3.random.RandomGenerator
-
nextBoolean
public boolean nextBoolean()- Specified by:
nextBoolean
in interfaceorg.apache.commons.math3.random.RandomGenerator
-
nextFloat
public float nextFloat()- Specified by:
nextFloat
in interfaceorg.apache.commons.math3.random.RandomGenerator
-
nextDouble
public double nextDouble()- Specified by:
nextDouble
in interfaceorg.apache.commons.math3.random.RandomGenerator
-
nextGaussian
public double nextGaussian()- Specified by:
nextGaussian
in interfaceorg.apache.commons.math3.random.RandomGenerator
-