Top Description Fields Constructors Methods
org.apache.commons.math3.random

public Class RandomAdaptor

extends Random
implements RandomGenerator
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.random.RandomGenerator
Imports
java.util.Random

Extension of java.util.Random wrapping a RandomGenerator.
Since
1.1

Field Summary

Modifier and TypeField and Description
private final RandomGenerator
randomGenerator

Wrapped randomGenerator instance

private static final long
serialVersionUID

Hides java.util.Random.serialVersionUID.

Serializable version identifier.

Constructor Summary

AccessConstructor and Description
private
RandomAdaptor()

Prevent instantiation without a generator argument

public
RandomAdaptor(RandomGenerator
the wrapped generator
randomGenerator
)

Construct a RandomAdaptor wrapping the supplied RandomGenerator.

Method Summary

Modifier and TypeMethod and Description
public static Random

Returns:

a Random instance wrapping the RandomGenerator
createAdaptor
(RandomGenerator
wrapped RandomGenerator instance
randomGenerator
)

Factory method to create a Random using the supplied RandomGenerator.

public boolean

Returns:

the next pseudorandom, uniformly distributed boolean value from this random number generator's sequence
nextBoolean
()

Overrides java.util.Random.nextBoolean.

Overrides default java.util.random.RandomGenerator.nextBoolean.

Implements org.apache.commons.math3.random.RandomGenerator.nextBoolean.

Returns the next pseudorandom, uniformly distributed boolean value from this random number generator's sequence.

public void
nextBytes(byte[]
the non-null byte array in which to put the random bytes
bytes
)

Overrides java.util.Random.nextBytes.

Overrides default java.util.random.RandomGenerator.nextBytes.

Implements org.apache.commons.math3.random.RandomGenerator.nextBytes.

Generates random bytes and places them into a user-supplied byte array.

public double

Returns:

the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence
nextDouble
()

Overrides java.util.Random.nextDouble.

Overrides default java.util.random.RandomGenerator.nextDouble.

Implements org.apache.commons.math3.random.RandomGenerator.nextDouble.

Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.

public float

Returns:

the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator's sequence
nextFloat
()

Overrides java.util.Random.nextFloat.

Overrides default java.util.random.RandomGenerator.nextFloat.

Implements org.apache.commons.math3.random.RandomGenerator.nextFloat.

Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator's sequence.

public double

Returns:

the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence
nextGaussian
()

Overrides java.util.Random.nextGaussian.

Overrides default java.util.random.RandomGenerator.nextGaussian.

Implements org.apache.commons.math3.random.RandomGenerator.nextGaussian.

Returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.

public int

Returns:

the next pseudorandom, uniformly distributed int value from this random number generator's sequence
nextInt
()

Overrides java.util.Random.nextInt.

Overrides default java.util.random.RandomGenerator.nextInt.

Implements org.apache.commons.math3.random.RandomGenerator.nextInt.

Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.

public int

Returns:

a pseudorandom, uniformly distributed int value between 0 (inclusive) and n (exclusive).
nextInt
(int
the bound on the random number to be returned. Must be positive.
n
)

Overrides java.util.Random.nextInt.

Overrides default java.util.random.RandomGenerator.nextInt.

Implements org.apache.commons.math3.random.RandomGenerator.nextInt.

Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.

public long

Returns:

the next pseudorandom, uniformly distributed long value from this random number generator's sequence
nextLong
()

Overrides java.util.Random.nextLong.

Implements org.apache.commons.math3.random.RandomGenerator.nextLong, java.util.random.RandomGenerator.nextLong.

Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence.

public void
setSeed(int
the seed value
seed
)

Implements org.apache.commons.math3.random.RandomGenerator.setSeed.

Sets the seed of the underlying random number generator using an int seed.

public void
setSeed(int[]
the seed value
seed
)

Implements org.apache.commons.math3.random.RandomGenerator.setSeed.

Sets the seed of the underlying random number generator using an int array seed.

public void
setSeed(long
the seed value
seed
)

Overrides java.util.Random.setSeed.

Implements org.apache.commons.math3.random.RandomGenerator.setSeed.

Sets the seed of the underlying random number generator using a long seed.

Inherited from java.util.Random:
doublesdoublesdoublesdoublesfromintsintsintsintslongslongslongslongsnext

Field Detail

randomGeneratorback to summary
private final RandomGenerator randomGenerator

Wrapped randomGenerator instance

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.Random.serialVersionUID.

Serializable version identifier.

Constructor Detail

RandomAdaptorback to summary
private RandomAdaptor()

Prevent instantiation without a generator argument

Annotations
@SuppressWarnings:unused
RandomAdaptorback to summary
public RandomAdaptor(RandomGenerator randomGenerator)

Construct a RandomAdaptor wrapping the supplied RandomGenerator.

Parameters
randomGenerator:RandomGenerator

the wrapped generator

Method Detail

createAdaptorback to summary
public static Random createAdaptor(RandomGenerator randomGenerator)

Factory method to create a Random using the supplied RandomGenerator.

Parameters
randomGenerator:RandomGenerator

wrapped RandomGenerator instance

Returns:Random

a Random instance wrapping the RandomGenerator

nextBooleanback to summary
public boolean nextBoolean()

Overrides java.util.Random.nextBoolean.

Overrides default java.util.random.RandomGenerator.nextBoolean.

Implements org.apache.commons.math3.random.RandomGenerator.nextBoolean.

Returns the next pseudorandom, uniformly distributed boolean value from this random number generator's sequence.

Returns:boolean

the next pseudorandom, uniformly distributed boolean value from this random number generator's sequence

Annotations
@Override
nextBytesback to summary
public void nextBytes(byte[] bytes)

Overrides java.util.Random.nextBytes.

Overrides default java.util.random.RandomGenerator.nextBytes.

Implements org.apache.commons.math3.random.RandomGenerator.nextBytes.

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.

Parameters
bytes:byte[]

the non-null byte array in which to put the random bytes

Annotations
@Override
nextDoubleback to summary
public double nextDouble()

Overrides java.util.Random.nextDouble.

Overrides default java.util.random.RandomGenerator.nextDouble.

Implements org.apache.commons.math3.random.RandomGenerator.nextDouble.

Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.

Returns:double

the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence

Annotations
@Override
nextFloatback to summary
public float nextFloat()

Overrides java.util.Random.nextFloat.

Overrides default java.util.random.RandomGenerator.nextFloat.

Implements org.apache.commons.math3.random.RandomGenerator.nextFloat.

Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator's sequence.

Returns:float

the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator's sequence

Annotations
@Override
nextGaussianback to summary
public double nextGaussian()

Overrides java.util.Random.nextGaussian.

Overrides default java.util.random.RandomGenerator.nextGaussian.

Implements org.apache.commons.math3.random.RandomGenerator.nextGaussian.

Returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.

Returns:double

the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence

Annotations
@Override
nextIntback to summary
public int nextInt()

Overrides java.util.Random.nextInt.

Overrides default java.util.random.RandomGenerator.nextInt.

Implements org.apache.commons.math3.random.RandomGenerator.nextInt.

Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence. All 232 possible int values should be produced with (approximately) equal probability.

Returns:int

the next pseudorandom, uniformly distributed int value from this random number generator's sequence

Annotations
@Override
nextIntback to summary
public int nextInt(int n)

Overrides java.util.Random.nextInt.

Overrides default java.util.random.RandomGenerator.nextInt.

Implements org.apache.commons.math3.random.RandomGenerator.nextInt.

Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.

Parameters
n:int

the bound on the random number to be returned. Must be positive.

Returns:int

a pseudorandom, uniformly distributed int value between 0 (inclusive) and n (exclusive).

Annotations
@Override
Exceptions
IllegalArgumentException:
if n is not positive.
nextLongback to summary
public long nextLong()

Overrides java.util.Random.nextLong.

Implements org.apache.commons.math3.random.RandomGenerator.nextLong, java.util.random.RandomGenerator.nextLong.

Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence. All 264 possible long values should be produced with (approximately) equal probability.

Returns:long

the next pseudorandom, uniformly distributed long value from this random number generator's sequence

Annotations
@Override
setSeedback to summary
public void setSeed(int seed)

Implements org.apache.commons.math3.random.RandomGenerator.setSeed.

Doc from org.apache.commons.math3.random.RandomGenerator.setSeed.

Sets the seed of the underlying random number generator using an int seed.

Sequences of values generated starting with the same seeds should be identical.

Parameters
seed:int

the seed value

setSeedback to summary
public void setSeed(int[] seed)

Implements org.apache.commons.math3.random.RandomGenerator.setSeed.

Doc from org.apache.commons.math3.random.RandomGenerator.setSeed.

Sets the seed of the underlying random number generator using an int array seed.

Sequences of values generated starting with the same seeds should be identical.

Parameters
seed:int[]

the seed value

setSeedback to summary
public void setSeed(long seed)

Overrides java.util.Random.setSeed.

Implements org.apache.commons.math3.random.RandomGenerator.setSeed.

Doc from org.apache.commons.math3.random.RandomGenerator.setSeed.

Sets the seed of the underlying random number generator using a long seed.

Sequences of values generated starting with the same seeds should be identical.

Parameters
seed:long

the seed value

Annotations
@Override