Class F2NL607
- java.lang.Object
-
- umontreal.iro.lecuyer.rng.RandomStreamBase
-
- umontreal.iro.lecuyer.rng.F2NL607
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, CloneableRandomStream, RandomStream
public class F2NL607 extends RandomStreamBase
Implements theRandomStreaminterface by using as a backbone generator the combination of the WELL607 proposed in (and implemented inWELL607) with a nonlinear generator. This nonlinear generator is made up of a small number of components (say n) combined via addition modulo 1. Each component contains an array already filled with a ``random'' permutation of {0,..., s - 1} where s is the size of the array. These numbers and the lengths of the components can be changed by the user. Each call to the generator uses the next number in each array (or the first one if we are at the end of the array). By default, there are 3 components of lengths 1019, 1021, and 1031, respectively. The non-linear generator is combined with the WELL using a bitwise XOR operation. This ensures that the new generator has at least as much equidistribution as the WELL607, as shown in.The combined generator has a period length of approximatively 2637. The values of V, W and Z are 2250, 2150, and 2400, respectively (see
RandomStreamfor their definition). The seed of the RNG has two part: the linear part is a 19-dimensional vector of 32-bit integers, while the nonlinear part is made up of a n-dimensional vector of indices, representing the position of the generator in each array of the nonlinear components.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description F2NL607()Constructs a new stream, initializing it at its beginning.F2NL607(java.lang.String name)Constructs a new stream with the identifier name (used in the toString method).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description F2NL607clone()Clones the current generator and return its copy.int[]getLinearState()Returns the current state of the linear part of the stream, represented as an array of 19 integers.static int[][]getNonLinearData()Return the data of all the components of the non-linear part of the random number generator.int[]getNonLinearState()Returns the current state of the non-linear part of the stream, represented as an array of n integers, where n is the number of components in the non-linear generator.voidresetNextSubstream()Reinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.voidresetStartStream()Reinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.voidresetStartSubstream()Reinitializes the stream to the beginning of its current substream: Cg is set to Bg.voidsetLinearSeed(int[] seed)This method is discouraged for normal use.static voidsetNonLinearData(int[][] data)Selects new data for the components of the non-linear generator.voidsetNonLinearSeed(int[] seed)This method is discouraged for normal use.static voidsetPackageLinearSeed(int[] seed)Sets the initial seed of the linear part of the class F2NL607 to the 19 integers of the vector seed[0..18].static voidsetPackageNonLinearSeed(int[] seed)Sets the non-linear part of the initial seed of the class F2NL607 to the n integers of the vector seed[0..n-1], where n is the number of components of the non-linear part.static voidsetScrambleData(RandomStream rand, int steps, int[] size)Selects new data for the components of the non-linear generator.java.lang.StringtoString()Returns a string containing the current state of this stream.-
Methods inherited from class umontreal.iro.lecuyer.rng.RandomStreamBase
formatState, formatStateFull, increasedPrecision, nextArrayOfDouble, nextArrayOfInt, nextDouble, nextInt
-
-
-
-
Constructor Detail
-
F2NL607
public F2NL607()
Constructs a new stream, initializing it at its beginning. Also makes sure that the seed of the next constructed stream is Z steps away. Sets its antithetic switch to false and sets the stream to normal precision mode (offers 32 bits of precision).
-
F2NL607
public F2NL607(java.lang.String name)
Constructs a new stream with the identifier name (used in the toString method).- Parameters:
name- name of the stream
-
-
Method Detail
-
resetStartStream
public void resetStartStream()
Description copied from interface:RandomStreamReinitializes the stream to its initial state Ig: Cg and Bg are set to Ig.- Specified by:
resetStartStreamin interfaceRandomStream- Specified by:
resetStartStreamin classRandomStreamBase
-
resetStartSubstream
public void resetStartSubstream()
Description copied from interface:RandomStreamReinitializes the stream to the beginning of its current substream: Cg is set to Bg.- Specified by:
resetStartSubstreamin interfaceRandomStream- Specified by:
resetStartSubstreamin classRandomStreamBase
-
resetNextSubstream
public void resetNextSubstream()
Description copied from interface:RandomStreamReinitializes the stream to the beginning of its next substream: Ng is computed, and Cg and Bg are set to Ng.- Specified by:
resetNextSubstreamin interfaceRandomStream- Specified by:
resetNextSubstreamin classRandomStreamBase
-
setPackageLinearSeed
public static void setPackageLinearSeed(int[] seed)
Sets the initial seed of the linear part of the class F2NL607 to the 19 integers of the vector seed[0..18]. This will be the initial seed (or seed) of the next created stream. At least one of the integers must be non-zero and if this integer is the last one, it must not be equal to 0x7FFFFFFF.- Parameters:
seed- array of 19 elements representing the seed
-
setLinearSeed
public void setLinearSeed(int[] seed)
This method is discouraged for normal use. Initializes the stream at the beginning of a stream with the initial linear seed seed[0..18]. The seed must satisfy the same conditions as in setPackageSeed. The non-linear seed is not modified; thus the non-linear part of the random number generator is reset to the beginning of the old stream. This method only affects the specified stream; the others are not modified. Hence after calling this method, the beginning of the streams will no longer be spaced Z values apart. For this reason, this method should only be used in very exceptional cases; proper use of the reset... methods and of the stream constructor is preferable.- Parameters:
seed- array of 19 elements representing the seed
-
getLinearState
public int[] getLinearState()
Returns the current state of the linear part of the stream, represented as an array of 19 integers.- Returns:
- the current state of the stream
-
setPackageNonLinearSeed
public static void setPackageNonLinearSeed(int[] seed)
Sets the non-linear part of the initial seed of the class F2NL607 to the n integers of the vector seed[0..n-1], where n is the number of components of the non-linear part. The default is n = 3. Each of the integers must be between 0 and the length of the corresponding component minus one. By default, the lengths are (1019, 1021, 1031).- Parameters:
seed- array of n elements representing the non-linear seed
-
setNonLinearSeed
public void setNonLinearSeed(int[] seed)
This method is discouraged for normal use. Initializes the stream at the beginning of a stream with the initial non-linear seed seed[0..n-1], where n is the number of components of the non-linear part of the generator. The linear seed is not modified so the linear part of the random number generator is reset to the beginning of the old stream. This method only affects the specified stream; the others are not modified. Hence after calling this method, the beginning of the streams will no longer be spaced Z values apart. For this reason, this method should only be used in very exceptional cases; proper use of the reset... methods and of the stream constructor is preferable.- Parameters:
seed-
-
getNonLinearState
public int[] getNonLinearState()
Returns the current state of the non-linear part of the stream, represented as an array of n integers, where n is the number of components in the non-linear generator.- Returns:
- the current state of the stream
-
getNonLinearData
public static int[][] getNonLinearData()
Return the data of all the components of the non-linear part of the random number generator. This data is explained in the introduction.- Returns:
- the data of the components
-
setNonLinearData
public static void setNonLinearData(int[][] data)
Selects new data for the components of the non-linear generator. The number of arrays in data will decide the number of components. Each of the arrays will be assigned to one of the components. The period of the resulting non-linear generator will be equal to the lowest common multiple of the lengths of the arrays. It is thus recommended to choose only prime length for the best results.NOTE : This method cannot be called if at least one instance of F2NL607 has been constructed. In that case, it will throw an
IllegalStateException.- Parameters:
data- the new data of the components- Throws:
java.lang.IllegalStateException- if an instance of the class was constructed before
-
setScrambleData
public static void setScrambleData(RandomStream rand, int steps, int[] size)
Selects new data for the components of the non-linear generator. The number of arrays in data will decide the number of components. Each of the arrays will be assigned to one of the components. The period of the resulting non-linear generator will be equal to the lowest common multiple of the lengths of the arrays. It is thus recommended to choose only prime length for the best results.NOTE : This method cannot be called if at least one instance of F2NL607 has been constructed. In that case, it will throw an
IllegalStateException.- Parameters:
rand- the random numbers source to do the scramblingsteps- number of time to do the scramblingsize- size of each components- Throws:
java.lang.IllegalStateException- if an instance of the class was constructed before
-
clone
public F2NL607 clone()
Clones the current generator and return its copy.- Specified by:
clonein interfaceCloneableRandomStream- Returns:
- A deep copy of the current generator
-
toString
public java.lang.String toString()
Description copied from interface:RandomStreamReturns a string containing the current state of this stream.- Specified by:
toStringin interfaceRandomStream- Specified by:
toStringin classRandomStreamBase- Returns:
- the state of the generator formated as a string
-
-
DMelt 3.0 © DataMelt by jWork.ORG