MetropolisHastingsMV

open class MetropolisHastingsMV(initialX: DoubleArray, val targetFun: FunctionMVIfc, val proposalFun: ProposalFunctionMVIfc, stream: RNStreamIfc = KSLRandom.nextRNStream(), batchStatistics: List<BatchStatistic> = createBatchStatistics(initialX.size)) : Observable<MetropolisHastingsMV> , MVSampleIfc, RNStreamChangeIfc, RNStreamControlIfc

An implementation for a multi-variable Metropolis Hasting process. The process is observable at each step

Parameters

initialX

the initial value to start generation process

targetFun

the target function

proposalFun

the proposal function

stream

the stream for accepting or rejecting the proposed state

batchStatistics

a list of BatchStatistics one for each dimension that have been configured to collect batch statistics on the dimensions. Default batch statistics are provided.

Constructors

Link copied to clipboard
constructor(initialX: DoubleArray, targetFun: FunctionMVIfc, proposalFun: ProposalFunctionMVIfc, stream: RNStreamIfc = KSLRandom.nextRNStream(), batchStatistics: List<BatchStatistic> = createBatchStatistics(initialX.size))

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
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

Tells the stream to start producing antithetic variates

Link copied to clipboard
open override val dimension: Int

the expected size of the array from sample()

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
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
open override var rnStream: RNStreamIfc

the underlying stream of random numbers

Link copied to clipboard
open val streamNumber: Int
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 fun asString(): String
Link copied to clipboard
open override fun attachObserver(observer: ObserverIfc<MetropolisHastingsMV>)

Allows the adding (attaching) of an observer to the observable

Link copied to clipboard

Returns the average for each dimension based on all observed values, without batching.

Link copied to clipboard

Returns a list of batching statistics for each dimension. the observations for each dimension are batched using the default batching algorithm in class BatchStatistic.

Link copied to clipboard
open override fun countObservers(): Int

Returns how many observers are currently attached to the observable

Link copied to clipboard
Link copied to clipboard
open override fun detachAllObservers()

Detaches all the observers from the observable

Link copied to clipboard
open override fun detachObserver(observer: ObserverIfc<MetropolisHastingsMV>)

Allows the deletion (removing) of an observer from the observable

Link copied to clipboard

Resets statistics and sets the initial state to the initial value or to the value found via the burn in period (if the burn in period was run).

Link copied to clipboard
open override fun isAttached(observer: ObserverIfc<MetropolisHastingsMV>): Boolean

Returns true if the observer is already attached

Link copied to clipboard

Moves the process one step. If the sampler is not initialized, it will be initialized. If it has already been initialized, it will not be re-initialized.

fun next(steps: Int): DoubleArray

Causes the process to advance through the number of steps and return the state associated with the last step taken. This allows the sampling to skip the number of steps between returned observations. If the sampler is not initialized, it will be initialized. If it has already been initialized, it will not be re-initialized. This is a convenience method which repeatedly calls the function next() for the specified number of steps.

Link copied to clipboard
fun <T> Observable<T>.observe(block: (T?) -> Unit)
Link copied to clipboard

Returns a list of the statistics collected across every dimension from all the observations without batching.

Link copied to clipboard
Link copied to clipboard
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

Resets the automatically collected statistics

Link copied to clipboard

The state of the sampler is initialized before running all the steps.

Link copied to clipboard
fun runWarmUpPeriod(warmUpAmount: Int)

Runs a warmup period and assigns the initial value of the process to the last value from the warmup process.

Link copied to clipboard
open override fun sample(array: DoubleArray)

Fills the supplied array with a sample of values. This method avoids the creation of a new array. The size of the array must match dimension

open fun sample(): DoubleArray

open fun sample(values: Array<DoubleArray>)

Fills the supplied array of arrays with randomly generated samples

open fun sample(sampleSize: Int): List<DoubleArray>

Generates a list holding the randomly generated arrays of the given dimension. Thus, the elements of the list are the arrays holding the sampled values.

Link copied to clipboard
open fun sampleByColumn(sampleSize: Int): Array<DoubleArray>

Generates a sample by columns of values. The returned array will hold arrays of values, with each element being an array of size sampleSize. That is a 2-D array with nRows = dimension and nColumns = sample size

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

Assigns the stream associated with the supplied number from the default RNStreamProvider