BatchStatistic

class BatchStatistic(theMinNumBatches: Int = MIN_NUM_BATCHES, theMinBatchSize: Int = MIN_NUM_OBS_PER_BATCH, theMinNumBatchesMultiple: Int = MAX_BATCH_MULTIPLE, theName: String? = null, values: DoubleArray? = null) : AbstractStatistic, BatchStatisticIfc(source)

This class automates the batching of observations that may be dependent. It computes the batch means of the batches and reports statistics across the batches. Suppose we have observations, Y(1), Y(2), Y(3), ... Y(n). This class specifies the minimum number of batches, the minimum number of observations per batch, and a maximum batch multiple. The defaults are 20, 16, and 2, respectively. This implies that the maximum number of batches will be 40 = (min number of batches times the maximum batch multiple). The class computes the average of each batch, which are called the batch means.

Once the minimum number of observations are observed, a batch is formed. As more and more observations are collected, more and more batches are formed until the maximum number of batches is reached. Then the batches are re-batched down so that there are 20 batches (the minimum number of batches). This re-batching essentially doubles the batch size and halves the number of batches. In other words, each sequential pair of batches are combined into one batch by averaging their batch means. The purpose of this batching process is to break up correlation structure within the data.

Confidence intervals and summary statistics can be reported across the batch means under the assumption that the batch means are independent. The lag-1 correlation of the batch means is available as well as the Von-Neumann test statistic for independence of the batch means.

Creates a BatchStatistic with the given name For example, if minNumBatches = 20 and maxNBMultiple = 2 then the maximum number of batches allowed will be 40. maxNBMultiple must be 2 or more.

Parameters

theMinNumBatches

The minimum number of batches, must be >= 2

theMinBatchSize

The minimum number of observations per batch, must be >= 2

theMinNumBatchesMultiple

The maximum number of batches as a multiple of the minimum number of batches.

theName

A String representing the name of the statistic

values

An array of values to collect on

Constructors

Link copied to clipboard
constructor(theMinNumBatches: Int = MIN_NUM_BATCHES, theMinBatchSize: Int = MIN_NUM_OBS_PER_BATCH, theMinNumBatchesMultiple: Int = MAX_BATCH_MULTIPLE, theName: String? = null, values: DoubleArray? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val amountLeftUnbatched: Double
Link copied to clipboard
open override val average: Double

Gets the unweighted average of the observations.

Link copied to clipboard
open override val batchMeans: DoubleArray

Returns a copy of the batch means array. Zero index is the first batch mean

Link copied to clipboard
open override var confidenceLevel: Double

Holds the confidence coefficient for the statistic

Link copied to clipboard
open override val count: Double

Gets the count for the number of the observations.

Link copied to clipboard
open override var currentBatchSize: Int

the size of the current batch

Link copied to clipboard

Returns a copy of the StatisticIfc that is tabulating the current batch

Link copied to clipboard
open override val deviationSumOfSquares: Double

Gets the sum of squares of the deviations from the average This is the numerator in the classic sample variance formula

Link copied to clipboard
open override val kurtosis: Double

Gets the kurtosis of the data

Link copied to clipboard
open override val lag1Correlation: Double

Gets the lag-1 generate correlation of the unweighted observations. Note: See Box, Jenkins, Reinsel, Time Series Analysis, 3rd edition, Prentice-Hall, pg 31

Link copied to clipboard
open override val lag1Covariance: Double

Gets the lag-1 generate covariance of the unweighted observations. Note: See Box, Jenkins, Reinsel, Time Series Analysis, 3rd edition, Prentice-Hall, pg 31

Link copied to clipboard
open override val max: Double

Gets the maximum of the observations.

Link copied to clipboard
open override val maxNumBatches: Int

The maximum number of batches as determined by the max num batches multiple

Link copied to clipboard
open override val min: Double

Gets the minimum of the observations.

Link copied to clipboard
open override val minBatchSize: Int

The minimum number of observations per batch

Link copied to clipboard
open override val minNumBatches: Int

The minimum number of batches required

Link copied to clipboard
open override val minNumBatchesMultiple: Int

The multiple of the minimum number of batches that determines the maximum number of batches e.g. if the min. number of batches is 20 and the max number batches multiple is 2, then we can have at most 40 batches

Link copied to clipboard
open override val negativeCount: Double

Counts the number of observations that were negative, strictly less than zero.

Link copied to clipboard
open override var numBatches: Int

the number of batches

Link copied to clipboard
open override var numRebatches: Int

the number of times re-batching has occurred

Link copied to clipboard
open override val skewness: Double

Gets the skewness of the data

Link copied to clipboard
open override val standardDeviation: Double

Gets the sample standard deviation of the observations. Simply the square root of variance

Link copied to clipboard
open override val standardError: Double

Gets the standard error of the observations. Simply the generate standard deviation divided by the square root of the number of observations

Link copied to clipboard
open override val sum: Double

Gets the sum of the observations.

Link copied to clipboard

Gets the total number of observations observed

Link copied to clipboard
open override val variance: Double

Gets the sample variance of the observations.

Link copied to clipboard

Gets the Von Neumann Lag 1 test statistic for checking the hypothesis that the data are uncorrelated Note: See Handbook of Simulation, Jerry Banks editor, McGraw-Hill, pg 253.

Link copied to clipboard

Returns the asymptotic p-value for the Von Nueumann Lag-1 Test Statistic:

Link copied to clipboard
open override val zeroCount: Double

Counts the number of observations that were exactly zero.

Functions

Link copied to clipboard
Link copied to clipboard
open override fun checkMean(mean: Double): Boolean

Checks if the supplied value falls within getAverage() +/- getHalfWidth()

Link copied to clipboard
open override fun collect(obs: Double)

Collect on the supplied value. Double.NaN, Double.NEGATIVE_INFINITY, and Double.POSITIVE_INFINITY values are counted as missing. Null values are not permitted.

Link copied to clipboard
open override fun copyOfAsStatistic(): Statistic

Return a copy of the information as an instance of a statistic

Link copied to clipboard
open override fun halfWidth(level: Double): Double

Gets the confidence interval half-width. Simply the standard error times the confidence coefficient as determined by an appropriate sampling distribution

Link copied to clipboard
open override fun instance(): BatchStatistic

Returns a copy of the BatchStatistic

Link copied to clipboard
open override fun leadingDigitRule(multiplier: Double): Int

Computes the right most meaningful digit according to (int)Math.floor(Math.log10(a*getStandardError())) See doi 10.1287.opre.1080.0529 by Song and Schmeiser

Link copied to clipboard
open override fun reformBatches(numBatches: Int): DoubleArray

Takes the current batch means and batches them into the specified number of batches. This does not change the current batch means

Link copied to clipboard
open override fun reset()

Resets the collector as if no observations had been collected.

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

Returns a String representation of the Statistic