RVariable
An abstract base class for building random variables. Implement the random generation procedure in the method generate().
A stream number selects a stream; it does not rewind one. Naming a stream reads as a request for reproducibility, and it delivers that only to the first consumer of the stream in the process. Two random variables constructed on the same stream number share one stream, so the second continues from wherever the first left it:
val a = ExponentialRV(10.0, streamNum = 16) val b = ExponentialRV(10.0, streamNum = 16) a.value // 35.3435, 22.7308, 7.8564, ... b.value // 0.1540, 42.7821, 7.1780, ... continues a's stream b.resetStartStream() b.value // 35.3435, 22.7308, 7.8564, ... now the same series
resetStartStream() is what rewinds. A function that builds a fixed data set from a named stream therefore returns a different data set the second time it is called, and the result changes with the order tests happen to run in — silently, since nothing about a shared stream is an error. Call resetStartStream() after construction when the intent is "this exact series".
Parameters
the random number stream number, defaults to 0, which means the next stream. Selecting a stream by number does not reset its position; see above.
the provider of random number streams, defaults to KSLRandom.DefaultRNStreamProvider
an optional name
Inheritors
Constructors
Properties
If true, the stream will automatically participate in having its stream advanced to the next sub-stream via stream managers
Tells the stream to start producing antithetic variates
The last (previous) randomly generated value. This value does not change until the next randomly generated value is obtained
If true, the stream will automatically participate in having its stream reset to its start stream via stream managers
rnStream provides a reference to the underlying stream of random numbers
Functions
Positions the RNG at the beginning of its next substream
An instance of the random variable with the stream provided by the same underlying stream provider
The resetStartStream method will position the RNG at the beginning of its stream. This is the same location in the stream as assigned when the RNG was created and initialized.
Resets the position of the RNG at the start of the current substream