Package jsl.utilities.statistic
Class StandardizedTimeSeriesStatistic
- java.lang.Object
-
- jsl.utilities.statistic.AbstractCollector
-
- jsl.utilities.statistic.AbstractStatistic
-
- jsl.utilities.statistic.StandardizedTimeSeriesStatistic
-
- All Implemented Interfaces:
java.lang.Comparable<AbstractStatistic>
,GetNameIfc
,IdentityIfc
,ArraySaverIfc
,CollectorIfc
,GetCSVStatisticIfc
,StatisticAccessorIfc
public class StandardizedTimeSeriesStatistic extends AbstractStatistic
Implements the Standardized Time Series method as described on page 534 of Law and Kelton, 3rd edition
-
-
Field Summary
Fields Modifier and Type Field Description static int
BATCH_SIZE
the default minimum number of observations per batch, the batch size-
Fields inherited from class jsl.utilities.statistic.AbstractStatistic
DEFAULT_CONFIDENCE_LEVEL, myConfidenceLevel, myNumMissing
-
Fields inherited from interface jsl.utilities.statistic.ArraySaverIfc
DEFAULT_DATA_ARRAY_SIZE
-
-
Constructor Summary
Constructors Constructor Description StandardizedTimeSeriesStatistic()
Creates an STS Statistic with the default batch size = 1024 The batch means will not be savedStandardizedTimeSeriesStatistic(boolean saveBMFlag)
Creates an STS Statistic with the default batch size = 1024 The batch means will not be savedStandardizedTimeSeriesStatistic(boolean saveBMFlag, double[] values)
Creates an STS Statistic with the default batch size = 1024 The batch means will not be savedStandardizedTimeSeriesStatistic(double[] values)
Creates an STS Statistic with the default batch size = 1024 The batch means will not be savedStandardizedTimeSeriesStatistic(int batchSize)
Creates an STS Statistic with the given batchsize.StandardizedTimeSeriesStatistic(int batchSize, boolean saveBMFlag)
Creates an STS Statistic with the given batch size.StandardizedTimeSeriesStatistic(int batchSize, boolean saveBMFlag, double[] values)
Creates an STS Statistic with the given batch size.StandardizedTimeSeriesStatistic(int batchSize, boolean saveBMFlag, java.lang.String name, double[] values)
Creates an STS Statistic with the given batch size.StandardizedTimeSeriesStatistic(int batchSize, double[] values)
Creates an STS Statistic with the given batchsize.StandardizedTimeSeriesStatistic(int batchSize, java.lang.String name)
Creates an STS Statistic with the given batch size and name.StandardizedTimeSeriesStatistic(int batchSize, java.lang.String name, double[] values)
Creates an STS Statistic with the given batch size and name.StandardizedTimeSeriesStatistic(java.lang.String name)
Creates an STS Statistic with the default batch size = 1024 The batch means will not be savedStandardizedTimeSeriesStatistic(java.lang.String name, double[] values)
Creates an STS Statistic with the default batch size = 1024 The batch means will not be saved
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
collect(double value)
Collect on the supplied valueStatisticAccessorIfc
getAcrossBatchStatistic()
Gets a StatisticAccessIfc that represents the across batch statisticsdouble
getAverage()
Gets the unweighted average of the observations.java.util.Iterator<Statistic>
getBatchMeansIterator()
Returns an iterator across all the batch means collected so fardouble
getCount()
Gets the count of the number of the observations.StatisticAccessorIfc
getCurrentBatchStatistic()
Gets a StatisticAccessIfc for the current batch that is being collected.double
getDeviationSumOfSquares()
Gets the sum of squares of the deviations from the average This is the numerator in the classic sample variance formuladouble
getHalfWidth(double alpha)
Gets the confidence interval half-width.double
getKurtosis()
Gets the kurtosis of the datadouble
getLag1Correlation()
Gets the lag-1 generate correlation of the unweighted observations.double
getLag1Covariance()
Gets the lag-1 generate covariance of the unweighted observations.double
getLastValue()
Gets the last observed data pointint
getLeadingDigitRule(double a)
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 Schmeiserdouble
getMax()
Gets the maximum of the observations.double
getMin()
Gets the minimum of the observations.double
getNumBatches()
Gets the number of batchesdouble
getSkewness()
Gets the skewness of the datadouble
getStandardDeviation()
Gets the sample standard deviation of the observations.double
getStandardError()
Gets the standard error of the observations.double
getSTSAreaConstant()
Computes an estimate of the STS Area Constantdouble
getSTSHalfWidth()
Computes the half-width of a STS based confidence interval based on a 95% confidence leveldouble
getSTSHalfWidth(double level)
Computes the half-width of a STS based confidence interval based on the supplied confidence coefficient.double
getSTSStandardError()
Gets the standard error for the STS confidence intervaldouble
getSum()
Gets the sum of the observations.StatisticAccessorIfc
getUnBatchedStatistic()
Gets a StatisticAccessorIfc that represents statistics that have been collected on each unbatched data point This is the same as using a Statistic on the datadouble
getVariance()
Gets the sample variance of the observations.double
getVonNeumannLag1TestStatistic()
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.double
getVonNeumannLag1TestStatisticPValue()
Returns the asymptotic p-value for the Von Nueumann Lag-1 Test Statistic:static void
main(java.lang.String[] args)
void
reset()
Resets the collector as if no observations had been collected.protected void
setBatchSize(int batchSize)
Sets the number of batches, must be >=2java.lang.String
toString()
Returns a String representation of the Statistic-
Methods inherited from class jsl.utilities.statistic.AbstractStatistic
compareTo, getConfidenceLevel, getNumberMissing, setConfidenceLevel
-
Methods inherited from class jsl.utilities.statistic.AbstractCollector
clearSavedData, getId, getName, getSavedData, getSaveOption, save, save, setArraySizeIncrement, setName, setSaveOption
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jsl.utilities.statistic.CollectorIfc
collect, collect, collect
-
Methods inherited from interface jsl.utilities.statistic.StatisticAccessorIfc
getConfidenceInterval, getConfidenceInterval, getCSVHeader, getCSVStatistic, getCSVStatisticHeader, getCSVValues, getHalfWidth, getName, getRelativeError, getRelativeWidth, getRelativeWidth, getStatistics, getStatisticsAsMap
-
-
-
-
Field Detail
-
BATCH_SIZE
public static final int BATCH_SIZE
the default minimum number of observations per batch, the batch size- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic()
Creates an STS Statistic with the default batch size = 1024 The batch means will not be saved
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic(java.lang.String name)
Creates an STS Statistic with the default batch size = 1024 The batch means will not be saved- Parameters:
name
- the name of the statistic
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic(boolean saveBMFlag)
Creates an STS Statistic with the default batch size = 1024 The batch means will not be saved- Parameters:
saveBMFlag
- Indicates whether or not the batch means will be saved, true means saved, false means not saved. False is the default
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic(boolean saveBMFlag, double[] values)
Creates an STS Statistic with the default batch size = 1024 The batch means will not be saved- Parameters:
saveBMFlag
- Indicates whether or not the batch means will be saved, true means saved, false means not saved. False is the defaultvalues
- an array of values to collect statistics on
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic(double[] values)
Creates an STS Statistic with the default batch size = 1024 The batch means will not be saved- Parameters:
values
- an array of values to collect statistics on
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic(java.lang.String name, double[] values)
Creates an STS Statistic with the default batch size = 1024 The batch means will not be saved- Parameters:
name
- The namevalues
- an array of values to collect statistics on
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic(int batchSize)
Creates an STS Statistic with the given batchsize. The batch means will not be saved- Parameters:
batchSize
- Must be >= 2
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic(int batchSize, double[] values)
Creates an STS Statistic with the given batchsize. The batch means will not be saved- Parameters:
batchSize
- Must be >= 2values
- an array of values to collect statistics on
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic(int batchSize, java.lang.String name)
Creates an STS Statistic with the given batch size and name. The batch means will not be save.- Parameters:
batchSize
- Must be >= 2name
- The name
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic(int batchSize, java.lang.String name, double[] values)
Creates an STS Statistic with the given batch size and name. The batch means will not be save.- Parameters:
batchSize
- Must be >= 2name
- The namevalues
- an array of values to collect statistics on
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic(int batchSize, boolean saveBMFlag)
Creates an STS Statistic with the given batch size.- Parameters:
batchSize
- Must be >=2saveBMFlag
- Indicates whether or not the batch means will be saved, true means saved, false means not saved. False is the default
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic(int batchSize, boolean saveBMFlag, double[] values)
Creates an STS Statistic with the given batch size.- Parameters:
batchSize
- Must be >=2saveBMFlag
- Indicates whether or not the batch means will be saved, true means saved, false means not saved. False is the defaultvalues
- an array of values to collect statistics on
-
StandardizedTimeSeriesStatistic
public StandardizedTimeSeriesStatistic(int batchSize, boolean saveBMFlag, java.lang.String name, double[] values)
Creates an STS Statistic with the given batch size.- Parameters:
batchSize
- Must be >=2saveBMFlag
- Indicates whether or not the batch means will be saved, true means saved, false means not saved. False is the defaultname
- The name of the statisticvalues
- an array of values to collect statistics on
-
-
Method Detail
-
getNumBatches
public final double getNumBatches()
Gets the number of batches- Returns:
- Returns the number of batches
-
collect
public final void collect(double value)
Description copied from interface:CollectorIfc
Collect on the supplied value- Parameters:
value
- a double representing the observation
-
reset
public final void reset()
Description copied from interface:CollectorIfc
Resets the collector as if no observations had been collected.
-
getCount
public final double getCount()
Description copied from interface:StatisticAccessorIfc
Gets the count of the number of the observations.- Returns:
- A double representing the count
-
getAverage
public final double getAverage()
Description copied from interface:StatisticAccessorIfc
Gets the unweighted average of the observations.- Returns:
- A double representing the average or Double.NaN if no observations.
-
getSum
public final double getSum()
Description copied from interface:StatisticAccessorIfc
Gets the sum of the observations.- Returns:
- A double representing the unweighted sum
-
getDeviationSumOfSquares
public final double getDeviationSumOfSquares()
Description copied from interface:StatisticAccessorIfc
Gets the sum of squares of the deviations from the average This is the numerator in the classic sample variance formula- Returns:
- A double representing the sum of squares of the deviations from the average
-
getVariance
public final double getVariance()
Description copied from interface:StatisticAccessorIfc
Gets the sample variance of the observations.- Returns:
- A double representing the generate variance or Double.NaN if 1 or less observations.
-
getStandardDeviation
public final double getStandardDeviation()
Description copied from interface:StatisticAccessorIfc
Gets the sample standard deviation of the observations. Simply the square root of getVariance()- Returns:
- A double representing the generate standard deviation or Double.NaN if 1 or less observations.
-
getHalfWidth
public final double getHalfWidth(double alpha)
Description copied from interface:StatisticAccessorIfc
Gets the confidence interval half-width. Simply the generate standard error times the confidence coefficient as determined by an appropriate sampling distribution- Parameters:
alpha
- the confidence level- Returns:
- A double representing the half-width or Double.NaN if < 1 observation
-
getMin
public final double getMin()
Description copied from interface:StatisticAccessorIfc
Gets the minimum of the observations.- Returns:
- A double representing the minimum
-
getMax
public final double getMax()
Description copied from interface:StatisticAccessorIfc
Gets the maximum of the observations.- Returns:
- A double representing the maximum
-
getLastValue
public final double getLastValue()
Description copied from interface:StatisticAccessorIfc
Gets the last observed data point- Returns:
- A double representing the last observations
-
getKurtosis
public final double getKurtosis()
Description copied from interface:StatisticAccessorIfc
Gets the kurtosis of the data- Returns:
- A double representing the kurtosis
-
getSkewness
public final double getSkewness()
Description copied from interface:StatisticAccessorIfc
Gets the skewness of the data- Returns:
- A double representing the skewness
-
getStandardError
public final double getStandardError()
Description copied from interface:StatisticAccessorIfc
Gets the standard error of the observations. Simply the generate standard deviation divided by the square root of the number of observations- Returns:
- A double representing the standard error or Double.NaN if < 1 observation
-
getLag1Correlation
public final double getLag1Correlation()
Description copied from interface:StatisticAccessorIfc
Gets the lag-1 generate correlation of the unweighted observations. Note: See Box, Jenkins, Reinsel, Time Series Analysis, 3rd edition, Prentice-Hall, pg 31- Returns:
- A double representing the generate correlation or Double.NaN if <=2 observations
-
getLag1Covariance
public final double getLag1Covariance()
Description copied from interface:StatisticAccessorIfc
Gets the lag-1 generate covariance of the unweighted observations. Note: See Box, Jenkins, Reinsel, Time Series Analysis, 3rd edition, Prentice-Hall, pg 31- Returns:
- A double representing the generate covariance or Double.NaN if <=2 observations
-
getVonNeumannLag1TestStatistic
public final double getVonNeumannLag1TestStatistic()
Description copied from interface:StatisticAccessorIfc
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.- Returns:
- A double representing the Von Neumann test statistic
-
getVonNeumannLag1TestStatisticPValue
public final double getVonNeumannLag1TestStatisticPValue()
Description copied from interface:StatisticAccessorIfc
Returns the asymptotic p-value for the Von Nueumann Lag-1 Test Statistic:Normal.stdNormalComplementaryCDF(getVonNeumannLag1TestStatistic());
- Returns:
- the p-value
-
getLeadingDigitRule
public final int getLeadingDigitRule(double a)
Description copied from interface:StatisticAccessorIfc
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- Parameters:
a
- the std error multiplier- Returns:
- the meaningful digit
-
getBatchMeansIterator
public final java.util.Iterator<Statistic> getBatchMeansIterator()
Returns an iterator across all the batch means collected so far- Returns:
- an iterator across all the batch means collected so far
-
getSTSStandardError
public final double getSTSStandardError()
Gets the standard error for the STS confidence interval- Returns:
- standard error for the STS confidence interval
-
getSTSHalfWidth
public final double getSTSHalfWidth()
Computes the half-width of a STS based confidence interval based on a 95% confidence level- Returns:
- the half-width of a STS based confidence interval based on a 95% confidence level
-
getSTSHalfWidth
public final double getSTSHalfWidth(double level)
Computes the half-width of a STS based confidence interval based on the supplied confidence coefficient.- Parameters:
level
- the confidence level- Returns:
- the half-width
-
getSTSAreaConstant
public final double getSTSAreaConstant()
Computes an estimate of the STS Area Constant- Returns:
- an estimate of the STS Area Constant
-
getAcrossBatchStatistic
public final StatisticAccessorIfc getAcrossBatchStatistic()
Gets a StatisticAccessIfc that represents the across batch statistics- Returns:
- Returns the statistic.
-
getCurrentBatchStatistic
public final StatisticAccessorIfc getCurrentBatchStatistic()
Gets a StatisticAccessIfc for the current batch that is being collected. This is a statistic on the data within the batch- Returns:
- Returns the statistic.
-
getUnBatchedStatistic
public final StatisticAccessorIfc getUnBatchedStatistic()
Gets a StatisticAccessorIfc that represents statistics that have been collected on each unbatched data point This is the same as using a Statistic on the data- Returns:
- Returns the statistic.
-
toString
public final java.lang.String toString()
Description copied from interface:StatisticAccessorIfc
Returns a String representation of the Statistic- Specified by:
toString
in interfaceStatisticAccessorIfc
- Overrides:
toString
in classjava.lang.Object
- Returns:
- A String with basic summary statistics
-
setBatchSize
protected final void setBatchSize(int batchSize)
Sets the number of batches, must be >=2- Parameters:
batchSize
- The number of batches to set
-
main
public static void main(java.lang.String[] args)
-
-