RVariableIfc

An interface for defining random variables. The methods sample() and getValue() gets a new value of the random variable sampled accordingly. The method getPreviousValue() returns the value from the last call to sample() or getValue(). The value returned by getPreviousValue() stays the same until the next call to sample() or getValue(). The methods sample() or getValue() always get the next random value. If sample() or getValue() is never called then getPreviousValue() returns Double.NaN. Use sample() or getValue() to get a new random value and use getPreviousValue() to get the last sampled value.

The preferred approach to creating random variables is to subclass RVariable.

Inheritors

Properties

Link copied to clipboard

If true, the stream will automatically participate in having its stream advanced to the next sub-stream via stream managers

Link copied to clipboard
abstract var antithetic: Boolean

Tells the stream to start producing antithetic variates

Link copied to clipboard
abstract val emitter: Emitter<Double>
Link copied to clipboard
abstract val previousValue: Double

The previous value from the sequence of values a double representing the last value in the sequence

Link copied to clipboard

If true, the stream will automatically participate in having its stream reset to its start stream via stream managers

Link copied to clipboard
abstract val streamNumber: Int
Link copied to clipboard
Link copied to clipboard
open override val value: Double

The randomly generated value. Each value will be different

Functions

Link copied to clipboard
abstract fun advanceToNextSubStream()

Positions the RNG at the beginning of its next substream

Link copied to clipboard

Creates an instance of the random variable that is independent of the underlying stream provider but has an underlying stream that is in the exact same state as the random variable's stream, except that it is set to produce antithetic pseudo-random numbers (1-u). That is, its stream is a clone and will produce the antithetic sequence of pseudo-random numbers (i.e. 1-u1, 1-u2, 1-u3,...).

Link copied to clipboard

Creates an instance of the random variable that is independent of the underlying stream provider but has an underlying stream that is in the exact same state as the random variable's stream. That is, its stream is a clone and will produce the same sequence of pseudo-random numbers (i.e. common random numbers).

Link copied to clipboard
open operator fun div(x: Double): RVariableIfc
open operator fun div(other: RVariableIfc): RVariableIfc
Link copied to clipboard
abstract fun instance(streamNum: Int = 0): RVariableIfc

An instance of the random variable with the stream provided by the same underlying stream provider

abstract override fun instance(streamNum: Int, rnStreamProvider: RNStreamProviderIfc): RVariableIfc
Link copied to clipboard
open operator fun minus(x: Double): RVariableIfc
open operator fun minus(other: RVariableIfc): RVariableIfc
Link copied to clipboard
open operator fun plus(x: Double): RVariableIfc
open operator fun plus(other: RVariableIfc): RVariableIfc
Link copied to clipboard
open fun pow(x: Double): RVariableIfc
Link copied to clipboard
abstract fun resetStartStream()

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.

Link copied to clipboard
abstract fun resetStartSubStream()

Resets the position of the RNG at the start of the current substream

Link copied to clipboard
abstract fun sample(): Double

open fun sample(sampleSize: Int): DoubleArray

Generates a random generated sample of the give size

Link copied to clipboard
open fun sampleAsColumns(sampleSize: Int, nCols: Int = 1): Array<DoubleArray>

Generates the number of columns nCols with each column holding a random sample of size sampleSize

Link copied to clipboard
open fun sampleAsRows(sampleSize: Int, nRows: Int = 1): Array<DoubleArray>

Generates the number of rows nRows with each row holding a random sample of size sampleSize

Link copied to clipboard
open fun sampleInto(matrix: Array<DoubleArray>)

Fills the supplied matrix with randomly generated values

open fun sampleInto(values: DoubleArray)

Fills the supplied array with randomly generated values

Link copied to clipboard
open fun sum(numInSum: Int): Double
Link copied to clipboard
open operator fun times(x: Double): RVariableIfc
open operator fun times(other: RVariableIfc): RVariableIfc
Link copied to clipboard
open override fun value(): Double

The randomly generated value. Each value will be different