jsat.utils.random
Class RandomUtil
- java.lang.Object
-
- jsat.utils.random.RandomUtil
-
public class RandomUtil extends java.lang.ObjectThis class provides assorted utilities related to random number generation and use.
-
-
Field Summary
Fields Modifier and Type Field and Description static java.util.concurrent.atomic.AtomicIntegerDEFAULT_SEEDIf not specified, this will be the seed used for random objects used internally within JSAT.
You may change this to any desired value at the start of any experiments to consistently get new experimental results.static booleanINCREMENT_SEEDSThis controls whether or notgetRandom()will cause a change in theDEFAULT_SEEDeach time it is called.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.util.RandomgetLocalRandom()Returns a Random object that is local to a given thread context, allowing re-usability at lower overhead.static java.util.RandomgetRandom()Returns a new Random object that can be used.static java.util.RandomgetRandom(int seed)Returns a new Random object that can be used, initiated with the given seed.
-
-
-
Field Detail
-
DEFAULT_SEED
public static java.util.concurrent.atomic.AtomicInteger DEFAULT_SEED
If not specified, this will be the seed used for random objects used internally within JSAT.
You may change this to any desired value at the start of any experiments to consistently get new experimental results. You may also change it at any point without ill effect, but the purpose is for consistent and repeatable experiments.
-
INCREMENT_SEEDS
public static boolean INCREMENT_SEEDS
This controls whether or notgetRandom()will cause a change in theDEFAULT_SEEDeach time it is called. This is the default to ensure that multiple calls to getRandom will not return an equivalent object.
-
-
Method Detail
-
getRandom
public static java.util.Random getRandom()
Returns a new Random object that can be used. The Random object returned is promised to be a reasonably high quality PSRND with low memory overhead that is faster to sample from than the default JavaRandom. Essentially, it will be better than Java's default PRNG in every way.
By default, multiple calls to this method will result in multiple, different, seeds. Controlling the base seed and its behavior can be done usingDEFAULT_SEEDandINCREMENT_SEEDS.- Returns:
- a new random number generator to use.
-
getRandom
public static java.util.Random getRandom(int seed)
Returns a new Random object that can be used, initiated with the given seed. The Random object returned is promised to be a reasonably high quality PSRND with low memory overhead that is faster to sample from than the default JavaRandom. Essentially, it will be better than Java's default PRNG in every way.- Parameters:
seed- the seed of the PRNG, which determines the sequence generated by the returned object- Returns:
- a new random number generator to use.
-
getLocalRandom
public static java.util.Random getLocalRandom()
Returns a Random object that is local to a given thread context, allowing re-usability at lower overhead. Once a Random object is created for a thread, it will continue to exist.- Returns:
- a Random object for use
-
-
DataMelt 3.0 © DataMelt by jWork.ORG