26package umontreal.ssj.rng;
28import umontreal.ssj.rng.RandomStream;
46 private double bminusa;
48 public TruncatedRandomStream(
RandomStream stream,
double a,
double b) {
50 throw new NullPointerException(
"The given stream must not be null");
52 throw new IllegalArgumentException(
"a must be smaller than b");
53 if (a < 0 || b < 0 || a > 1 || b > 1)
54 throw new IllegalArgumentException(
"a and b must be in [0, 1]");
61 stream.resetStartStream();
65 stream.resetStartSubstream();
69 stream.resetNextSubstream();
73 double v = stream.nextDouble();
74 return a + v * bminusa;
78 stream.nextArrayOfDouble(u, start, n);
79 for (
int i = start; i < start + n; i++)
80 u[i] = a + u[i] * bminusa;
88 for (
int x = start; x < start + n; x++)
void resetStartStream()
Reinitializes the stream to its initial state : and are set to .
void resetNextSubstream()
Reinitializes the stream to the beginning of its next substream:
void nextArrayOfDouble(double[] u, int start, int n)
Generates n (pseudo)random numbers from the uniform distribution and stores them into the array u sta...
double nextDouble()
Returns a (pseudo)random number from the uniform distribution over the interval , using this stream,...
int nextInt(int i, int j)
Returns a (pseudo)random number from the discrete uniform distribution over the integers ,...
void nextArrayOfInt(int i, int j, int[] u, int start, int n)
Generates n (pseudo)random numbers from the discrete uniform distribution over the integers ,...
void resetStartSubstream()
Reinitializes the stream to the beginning of its current substream:
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...