RNStream

Instances of RNStream are what is made by the factory. Each created stream should be 2 to 127 {@literal 2^127} steps ahead of the last stream created.

Constructors

Link copied to clipboard
constructor(sName: String? = null)

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
open override var antithetic: Boolean

This stream generates antithetic variates if and only if {\tt antithetic = true}.

Link copied to clipboard
open override val antitheticValue: Double

Returns the antithetic value of the previous value

Link copied to clipboard
open override val id: Int

The id of this object

Link copied to clipboard
open override var label: String?
Link copied to clipboard
open override val name: String

Describes the stream (for writing the state, error messages, etc.).

Link copied to clipboard
open override var previousU: Double

The previous U generated (returned) by randU01()

Link copied to clipboard
open override var resetStartStreamOption: Boolean

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

Link copied to clipboard

Functions

Link copied to clipboard
open override fun advanceToNextSubStream()

Positions the RNG at the beginning of its next substream

Link copied to clipboard
open override fun antitheticInstance(name: String?): RNStreamIfc
Link copied to clipboard
open override fun crnInstance(name: String?): RNStreamIfc

Returns a copy of the stream that has exactly the same state

Link copied to clipboard
open fun discreteInverseCDF(array: IntArray, cdf: DoubleArray): Int

Randomly selects from the array using the supplied cdf, NO checking of arrays

Link copied to clipboard
open fun <T> permute(x: Array<T>)
open fun permute(x: BooleanArray)

Randomly permutes the supplied array using the stream. The array is changed.

open fun permute(x: DoubleArray)

Randomly permutes the supplied array

open fun permute(x: IntArray)

Randomly permutes the supplied array, the array is changed.

open fun <T> permute(x: MutableList<T>)

Randomly permutes the supplied List using the stream. The list is changed.

Link copied to clipboard
open fun randInt(range: IntRange): Int

A convenience function for allowing the range to be specified via a range

open fun randInt(i: Int, j: Int): Int

Returns a (pseudo)random number from the discrete uniform distribution over the integers {i, i + 1, . . . , j }, using this stream. Calls randU01 once.

Link copied to clipboard
open fun randomlySelect(array: IntArray): Int

Randomly select an element from the array

open fun randomlySelect(array: IntArray, cdf: DoubleArray): Int

Randomly selects from the array using the supplied cdf

Link copied to clipboard
open override fun randU01(): Double

Returns a pseudo-random uniformly distributed number

Link copied to clipboard
open fun rBernoulli(pSuccess: Double = 0.5): Double
Link copied to clipboard
open fun rBernoulliBoolean(pSuccess: Double = 0.5): Boolean
Link copied to clipboard
open fun rBeta(alpha: Double, beta: Double): Double

This beta is restricted to the range of (0,1)

Link copied to clipboard
open fun rBetaG(alpha: Double, beta: Double, minimum: Double, maximum: Double): Double

This beta is restricted to the range of (minimum,maximum)

Link copied to clipboard
open fun rBinomial(pSuccess: Double, nTrials: Int): Int
Link copied to clipboard
open fun rChiSquared(dof: Double): Double
Link copied to clipboard
open fun rDUniform(range: IntRange): Int
open fun rDUniform(minimum: Int, maximum: Int): Int

Generates a discrete uniform over the range

Link copied to clipboard
open override 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
open override fun resetStartSubStream()

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

Link copied to clipboard
open fun rExponential(mean: Double): Double
Link copied to clipboard
open fun rGamma(shape: Double, scale: Double, type: KSLRandom.AlgoType = AlgoType.Inverse): Double
Link copied to clipboard
open fun rGeometric(pSuccess: Double): Int
Link copied to clipboard
open fun rJohnsonB(alpha1: Double, alpha2: Double, min: Double, max: Double): Double
Link copied to clipboard
open fun rLaplace(location: Double, scale: Double): Double

Generates according to a Laplace(location, scale)

Link copied to clipboard
open fun rLogistic(location: Double, scale: Double): Double
Link copied to clipboard
open fun rLogLogistic(shape: Double, scale: Double): Double
Link copied to clipboard
open fun rLogNormal(mean: Double, variance: Double): Double
Link copied to clipboard
open fun rNegBinomial(pSuccess: Double, rSuccesses: Double): Int
Link copied to clipboard
open fun rNormal(mean: Double = 0.0, variance: Double = 1.0): Double
Link copied to clipboard
open fun rPearsonType5(shape: Double, scale: Double): Double
Link copied to clipboard
open fun rPearsonType6(alpha1: Double, alpha2: Double, beta: Double): Double

Pearson Type 6

Link copied to clipboard
open fun rPoisson(mean: Double): Int
Link copied to clipboard
open fun rSign(pSuccess: Double = 0.5): Double

Returns a randomly generated sign -1 or +1

Link copied to clipboard
open fun rSignWithZero(): Double

Returns a randomly generated sign -1, 0, +1 all equally likely.

Link copied to clipboard
open fun rTriangular(min: Double, mode: Double, max: Double): Double
Link copied to clipboard
open fun rUniform(minimum: Double = 0.0, maximum: Double = 1.0): Double

Generates a continuous uniform over the range

Link copied to clipboard
open fun rWeibull(shape: Double, scale: Double): Double
Link copied to clipboard
open fun <T> sampleWithoutReplacement(x: Array<T>, sampleSize: Int)

The array x is changed, such that the first sampleSize elements contain the generated sample. That is, x0, x1, ... , xsampleSize-1 is the randomly sampled values without replacement

open fun sampleWithoutReplacement(x: BooleanArray, sampleSize: Int)
open fun sampleWithoutReplacement(x: IntArray, sampleSize: Int)

The array x is changed, such that the first sampleSize elements contain the generated sample. That is, x0, x1, ... , xsampleSize-1 is the random sample without replacement

open fun sampleWithoutReplacement(x: DoubleArray, sampleSize: Int)

The array x is changed, such that the first sampleSize elements contain the sample. That is, x0, x1, ... , xsampleSize-1 is the random sample without replacement

open fun <T> sampleWithoutReplacement(x: MutableList<T>, sampleSize: Int)

The List x is changed, such that the first sampleSize elements contain the sampled values. That is, x.get(0), x.get(1), ... , x.get(sampleSize-1) is the random sample without replacement

Link copied to clipboard

Returns the seed for the start of the sub-stream

Link copied to clipboard

Returns the current state C_g of this stream. This is a vector of 6 integers. This method is convenient if we want to save the state for subsequent use.

Link copied to clipboard
open override fun toString(): String