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

public abstract Class AbstractWell

extends BitsStreamGenerator
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
org.apache.commons.math3.random.Well1024a, org.apache.commons.math3.random.Well19937a, org.apache.commons.math3.random.Well19937c, org.apache.commons.math3.random.Well44497a, org.apache.commons.math3.random.Well44497b, org.apache.commons.math3.random.Well512a
Imports
java.io.Serializable, org.apache.commons.math3.util.FastMath

This abstract class implements the WELL class of pseudo-random number generator from François Panneton, Pierre L'Ecuyer and Makoto Matsumoto.

This generator is described in a paper by François Panneton, Pierre L'Ecuyer and Makoto Matsumoto Improved Long-Period Generators Based on Linear Recurrences Modulo 2 ACM Transactions on Mathematical Software, 32, 1 (2006). The errata for the paper are in wellrng-errata.txt.

Since
2.2
See Also
WELL Random number generator

Field Summary

Modifier and TypeField and Description
protected final int[]
i1

Index indirection table giving for each index the value index + m1 taking table size into account.

protected final int[]
i2

Index indirection table giving for each index the value index + m2 taking table size into account.

protected final int[]
i3

Index indirection table giving for each index the value index + m3 taking table size into account.

protected int
index

Current index in the bytes pool.

protected final int[]
iRm1

Index indirection table giving for each index its predecessor taking table size into account.

protected final int[]
iRm2

Index indirection table giving for each index its second predecessor taking table size into account.

private static final long
protected final int[]
v

Bytes pool.

Constructor Summary

AccessConstructor and Description
protected
AbstractWell(final int
number of bits in the pool (not necessarily a multiple of 32)
k
,
final int
first parameter of the algorithm
m1
,
final int
second parameter of the algorithm
m2
,
final int
third parameter of the algorithm
m3
)

Creates a new random number generator.

protected
AbstractWell(final int
number of bits in the pool (not necessarily a multiple of 32)
k
,
final int
first parameter of the algorithm
m1
,
final int
second parameter of the algorithm
m2
,
final int
third parameter of the algorithm
m3
,
final int
the initial seed (32 bits integer)
seed
)

Creates a new random number generator using a single int seed.

protected
AbstractWell(final int
number of bits in the pool (not necessarily a multiple of 32)
k
,
final int
first parameter of the algorithm
m1
,
final int
second parameter of the algorithm
m2
,
final int
third parameter of the algorithm
m3
,
final int[]
the initial seed (32 bits integers array), if null the seed of the generator will be related to the current time
seed
)

Creates a new random number generator using an int array seed.

protected
AbstractWell(final int
number of bits in the pool (not necessarily a multiple of 32)
k
,
final int
first parameter of the algorithm
m1
,
final int
second parameter of the algorithm
m2
,
final int
third parameter of the algorithm
m3
,
final long
the initial seed (64 bits integer)
seed
)

Creates a new random number generator using a single long seed.

Method Summary

Modifier and TypeMethod and Description
protected abstract int
next(final int
number of random bits to produce
bits
)

Implements abstract org.apache.commons.math3.random.BitsStreamGenerator.next.

Generate next pseudorandom number.

public void
setSeed(final int
the initial seed (32 bits integer)
seed
)

Implements abstract org.apache.commons.math3.random.BitsStreamGenerator.setSeed.

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

Reinitialize the generator as if just built with the given int seed.

public void
setSeed(final int[]
the initial seed (32 bits integers array). If null the seed of the generator will be the system time plus the system identity hash code of the instance.
seed
)

Implements abstract org.apache.commons.math3.random.BitsStreamGenerator.setSeed.

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

Reinitialize the generator as if just built with the given int array seed.

public void
setSeed(final long
the initial seed (64 bits integer)
seed
)

Implements abstract org.apache.commons.math3.random.BitsStreamGenerator.setSeed.

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

Reinitialize the generator as if just built with the given long seed.

Inherited from org.apache.commons.math3.random.BitsStreamGenerator:
clearnextBooleannextBytesnextBytesnextDoublenextFloatnextGaussiannextIntnextIntnextLongnextLong

Field Detail

i1back to summary
protected final int[] i1

Index indirection table giving for each index the value index + m1 taking table size into account.

i2back to summary
protected final int[] i2

Index indirection table giving for each index the value index + m2 taking table size into account.

i3back to summary
protected final int[] i3

Index indirection table giving for each index the value index + m3 taking table size into account.

indexback to summary
protected int index

Current index in the bytes pool.

iRm1back to summary
protected final int[] iRm1

Index indirection table giving for each index its predecessor taking table size into account.

iRm2back to summary
protected final int[] iRm2

Index indirection table giving for each index its second predecessor taking table size into account.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.math3.random.BitsStreamGenerator.serialVersionUID.

Serializable version identifier.

vback to summary
protected final int[] v

Bytes pool.

Constructor Detail

AbstractWellback to summary
protected AbstractWell(final int k, final int m1, final int m2, final int m3)

Creates a new random number generator.

The instance is initialized using the current time plus the system identity hash code of this instance as the seed.

Parameters
k:int

number of bits in the pool (not necessarily a multiple of 32)

m1:int

first parameter of the algorithm

m2:int

second parameter of the algorithm

m3:int

third parameter of the algorithm

AbstractWellback to summary
protected AbstractWell(final int k, final int m1, final int m2, final int m3, final int seed)

Creates a new random number generator using a single int seed.

Parameters
k:int

number of bits in the pool (not necessarily a multiple of 32)

m1:int

first parameter of the algorithm

m2:int

second parameter of the algorithm

m3:int

third parameter of the algorithm

seed:int

the initial seed (32 bits integer)

AbstractWellback to summary
protected AbstractWell(final int k, final int m1, final int m2, final int m3, final int[] seed)

Creates a new random number generator using an int array seed.

Parameters
k:int

number of bits in the pool (not necessarily a multiple of 32)

m1:int

first parameter of the algorithm

m2:int

second parameter of the algorithm

m3:int

third parameter of the algorithm

seed:int[]

the initial seed (32 bits integers array), if null the seed of the generator will be related to the current time

AbstractWellback to summary
protected AbstractWell(final int k, final int m1, final int m2, final int m3, final long seed)

Creates a new random number generator using a single long seed.

Parameters
k:int

number of bits in the pool (not necessarily a multiple of 32)

m1:int

first parameter of the algorithm

m2:int

second parameter of the algorithm

m3:int

third parameter of the algorithm

seed:long

the initial seed (64 bits integer)

Method Detail

nextback to summary
protected abstract int next(final int bits)

Implements abstract org.apache.commons.math3.random.BitsStreamGenerator.next.

Doc from org.apache.commons.math3.random.BitsStreamGenerator.next.

Generate next pseudorandom number.

This method is the core generation algorithm. It is used by all the public generation methods for the various primitive types nextBoolean(), nextBytes(byte[]), nextDouble(), nextFloat(), nextGaussian(), nextInt(), next(int) and nextLong().

Parameters
bits:int

number of random bits to produce

Returns:int

random bits generated

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

Implements abstract org.apache.commons.math3.random.BitsStreamGenerator.setSeed.

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

Reinitialize the generator as if just built with the given int seed.

The state of the generator is exactly the same as a new generator built with the same seed.

Parameters
seed:int

the initial seed (32 bits integer)

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

Implements abstract org.apache.commons.math3.random.BitsStreamGenerator.setSeed.

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

Reinitialize the generator as if just built with the given int array seed.

The state of the generator is exactly the same as a new generator built with the same seed.

Parameters
seed:int[]

the initial seed (32 bits integers array). If null the seed of the generator will be the system time plus the system identity hash code of the instance.

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

Implements abstract org.apache.commons.math3.random.BitsStreamGenerator.setSeed.

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

Reinitialize the generator as if just built with the given long seed.

The state of the generator is exactly the same as a new generator built with the same seed.

Parameters
seed:long

the initial seed (64 bits integer)

Annotations
@Override