umontreal.iro.lecuyer.rng
Class TruncatedRandomStream
- java.lang.Object
-
- umontreal.iro.lecuyer.rng.TruncatedRandomStream
-
- All Implemented Interfaces:
- RandomStream
public class TruncatedRandomStream extends java.lang.Object implements RandomStream
Represents a container random stream generating numbers in an interval (a, b) instead of in (0, 1), where 0 <= a < b <= 1, by using the contained stream. If nextDouble returns u for the contained stream, it will return v = a + (b - a)u, which is uniform over (a, b), for the truncated stream. The method nextInt returns the integer that corresponds to v (by inversion); this integer is no longer uniformly distributed in general.
-
-
Constructor Summary
Constructors Constructor and Description TruncatedRandomStream(RandomStream stream, double a, double b)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidnextArrayOfDouble(double[] u, int start, int n)Generates n (pseudo)random numbers from the uniform distribution and stores them into the array u starting at index start.voidnextArrayOfInt(int i, int j, int[] u, int start, int n)Generates n (pseudo)random numbers from the discrete uniform distribution over the integers {i, i + 1,..., j}, using this stream and stores the result in the array u starting at index start.doublenextDouble()Returns a (pseudo)random number from the uniform distribution over the interval (0, 1), using this stream, after advancing its state by one step.intnextInt(int i, int j)Returns a (pseudo)random number from the discrete uniform distribution over the integers {i, i + 1,..., j}, using this stream.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.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface umontreal.iro.lecuyer.rng.RandomStream
toString
-
-
-
-
Constructor Detail
-
TruncatedRandomStream
public TruncatedRandomStream(RandomStream stream, double a, double b)
-
-
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
-
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
-
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
-
nextDouble
public double nextDouble()
Description copied from interface:RandomStreamReturns a (pseudo)random number from the uniform distribution over the interval (0, 1), using this stream, after advancing its state by one step. The generators programmed in SSJ never return the values 0 or 1.- Specified by:
nextDoublein interfaceRandomStream- Returns:
- the next generated uniform
-
nextArrayOfDouble
public void nextArrayOfDouble(double[] u, int start, int n)Description copied from interface:RandomStreamGenerates n (pseudo)random numbers from the uniform distribution and stores them into the array u starting at index start.- Specified by:
nextArrayOfDoublein interfaceRandomStream- Parameters:
u- array that will contain the generated uniformsstart- starting index, in the array u, to write uniforms fromn- number of uniforms to generate
-
nextInt
public int nextInt(int i, int j)Description copied from interface:RandomStreamReturns a (pseudo)random number from the discrete uniform distribution over the integers {i, i + 1,..., j}, using this stream. (Calls nextDouble once.)- Specified by:
nextIntin interfaceRandomStream- Parameters:
i- smallest integer that can be generatedj- greatest integer that can be generated- Returns:
- the generated integer
-
nextArrayOfInt
public void nextArrayOfInt(int i, int j, int[] u, int start, int n)Description copied from interface:RandomStreamGenerates n (pseudo)random numbers from the discrete uniform distribution over the integers {i, i + 1,..., j}, using this stream and stores the result in the array u starting at index start. (Calls nextInt n times.)- Specified by:
nextArrayOfIntin interfaceRandomStream- Parameters:
i- smallest integer that can be generatedj- greatest integer that can be generatedu- array that will contain the generated valuesstart- starting index, in the array u, to write integers fromn- number of values being generated
-
-
DMelt 3.0 © DataMelt by jWork.ORG