Package org.apache.commons.math4.random
Class RngAdaptor
- java.lang.Object
-
- org.apache.commons.math4.random.RngAdaptor
-
- All Implemented Interfaces:
java.io.Serializable,RandomGenerator
@Deprecated public final class RngAdaptor extends java.lang.Object implements RandomGenerator, java.io.Serializable
Deprecated.As of 4.0. This class is made available for testing thenew RNG implementationsin existing applications. It will be removed in the next major release.Adaptor that delegates to aUniformRandomProviderinstance.It is provided for users who wish to test the new RNG implementations the current generators (up to version 3.6 of Commons Math) in codes that require the
RandomGeneratorinterface.Applications should upgrade to use the new generators ASAP. If problems are found that jeopardize the upgrade, please report them on the project's issue tracking system.
Notes:
-
The
setSeed(int),setSeed(int[])andsetSeed(long)methods of theRandomGeneratorare not part of thenew API. -
The new RNG implementations are not
Serializable. UseRestorableUniformRandomProvider.saveState()instead. -
nextGaussian()is not part of thenew APIas it defines a "post-processing" of the output of a uniform RNG in order to follow a different distribution.
- Since:
- 4.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RngAdaptor(RandomSource source)Deprecated.Creates a new instance.RngAdaptor(RandomSource source, java.lang.Object seed)Deprecated.Creates a new instance.
-
Method Summary
Modifier and Type Method Description booleannextBoolean()Deprecated.Returns the next pseudorandom, uniformly distributedbooleanvalue from this random number generator's sequence.voidnextBytes(byte[] bytes)Deprecated.Generates random bytes and places them into a user-supplied byte array.doublenextDouble()Deprecated.Returns the next pseudorandom, uniformly distributeddoublevalue between0.0and1.0from this random number generator's sequence.floatnextFloat()Deprecated.Returns the next pseudorandom, uniformly distributedfloatvalue between0.0and1.0from this random number generator's sequence.doublenextGaussian()Deprecated.Returns the next pseudorandom, Gaussian ("normally") distributeddoublevalue with mean0.0and standard deviation1.0from this random number generator's sequence.intnextInt()Deprecated.Returns the next pseudorandom, uniformly distributedintvalue from this random number generator's sequence.intnextInt(int n)Deprecated.Returns a pseudorandom, uniformly distributedintvalue between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.longnextLong()Deprecated.Returns the next pseudorandom, uniformly distributedlongvalue from this random number generator's sequence.voidsetSeed(int seed)Deprecated.Sets the seed of the underlying random number generator using anintseed.voidsetSeed(int[] seed)Deprecated.Sets the seed of the underlying random number generator using anintarray seed.voidsetSeed(long seed)Deprecated.Sets the seed of the underlying random number generator using alongseed.
-
-
-
Constructor Detail
-
RngAdaptor
public RngAdaptor(RandomSource source)
Deprecated.Creates a new instance.- Parameters:
source- Source of randomness.
-
RngAdaptor
public RngAdaptor(RandomSource source, java.lang.Object seed)
Deprecated.Creates a new instance.- Parameters:
source- Source of randomness.seed- Seed. Can benull.
-
-
Method Detail
-
setSeed
public void setSeed(int seed)
Deprecated.Sets the seed of the underlying random number generator using anintseed.Sequences of values generated starting with the same seeds should be identical.
- Specified by:
setSeedin interfaceRandomGenerator- Parameters:
seed- the seed value
-
setSeed
public void setSeed(int[] seed)
Deprecated.Sets the seed of the underlying random number generator using anintarray seed.Sequences of values generated starting with the same seeds should be identical.
- Specified by:
setSeedin interfaceRandomGenerator- Parameters:
seed- the seed value
-
setSeed
public void setSeed(long seed)
Deprecated.Sets the seed of the underlying random number generator using alongseed.Sequences of values generated starting with the same seeds should be identical.
- Specified by:
setSeedin interfaceRandomGenerator- Parameters:
seed- the seed value
-
nextBoolean
public boolean nextBoolean()
Deprecated.Returns the next pseudorandom, uniformly distributedbooleanvalue from this random number generator's sequence.- Specified by:
nextBooleanin interfaceRandomGenerator- Returns:
- the next pseudorandom, uniformly distributed
booleanvalue from this random number generator's sequence
-
nextBytes
public void nextBytes(byte[] bytes)
Deprecated.Generates random bytes and places them into a user-supplied byte array. The number of random bytes produced is equal to the length of the byte array.- Specified by:
nextBytesin interfaceRandomGenerator- Parameters:
bytes- the non-null byte array in which to put the random bytes
-
nextDouble
public double nextDouble()
Deprecated.Returns the next pseudorandom, uniformly distributeddoublevalue between0.0and1.0from this random number generator's sequence.- Specified by:
nextDoublein interfaceRandomGenerator- Returns:
- the next pseudorandom, uniformly distributed
doublevalue between0.0and1.0from this random number generator's sequence
-
nextFloat
public float nextFloat()
Deprecated.Returns the next pseudorandom, uniformly distributedfloatvalue between0.0and1.0from this random number generator's sequence.- Specified by:
nextFloatin interfaceRandomGenerator- Returns:
- the next pseudorandom, uniformly distributed
floatvalue between0.0and1.0from this random number generator's sequence
-
nextGaussian
public double nextGaussian()
Deprecated.Returns the next pseudorandom, Gaussian ("normally") distributeddoublevalue with mean0.0and standard deviation1.0from this random number generator's sequence.- Specified by:
nextGaussianin interfaceRandomGenerator- Returns:
- the next pseudorandom, Gaussian ("normally") distributed
doublevalue with mean0.0and standard deviation1.0from this random number generator's sequence
-
nextInt
public int nextInt()
Deprecated.Returns the next pseudorandom, uniformly distributedintvalue from this random number generator's sequence. All 232 possibleintvalues should be produced with (approximately) equal probability.- Specified by:
nextIntin interfaceRandomGenerator- Returns:
- the next pseudorandom, uniformly distributed
intvalue from this random number generator's sequence
-
nextInt
public int nextInt(int n)
Deprecated.Returns a pseudorandom, uniformly distributedintvalue between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.- Specified by:
nextIntin interfaceRandomGenerator- Parameters:
n- the bound on the random number to be returned. Must be positive.- Returns:
- a pseudorandom, uniformly distributed
intvalue between 0 (inclusive) and n (exclusive).
-
nextLong
public long nextLong()
Deprecated.Returns the next pseudorandom, uniformly distributedlongvalue from this random number generator's sequence. All 264 possiblelongvalues should be produced with (approximately) equal probability.- Specified by:
nextLongin interfaceRandomGenerator- Returns:
- the next pseudorandom, uniformly distributed
longvalue from this random number generator's sequence
-
-