Package jsl.utilities.random.sp
Class IntermittentDemandStatistic
- java.lang.Object
-
- jsl.utilities.random.sp.IntermittentDemandStatistic
-
- All Implemented Interfaces:
ObserverIfc,GetNameIfc,IdentityIfc,GetCSVStatisticIfc,StatisticAccessorIfc
public class IntermittentDemandStatistic extends java.lang.Object implements StatisticAccessorIfc, IdentityIfc, ObserverIfc
Implements the statistics estimator for an intermittent demand scenario
-
-
Constructor Summary
Constructors Constructor Description IntermittentDemandStatistic()IntermittentDemandStatistic(java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcollect(double data)voidcollect(double[] data)doublegetAverage()Gets the unweighted average of the observations.IntervalgetConfidenceInterval()A confidence interval for the mean based on the confidence levelIntervalgetConfidenceInterval(double alpha)A confidence interval for the mean based on the confidence leveldoublegetConfidenceLevel()Gets the confidence level.doublegetCount()Gets the count of the number of the observations.java.lang.StringgetCSVStatistic()NOT IMPLEMENTED YETjava.lang.StringgetCSVStatisticHeader()NOT IMPLEMENTED YETdouble[]getDemandsData()StatisticgetDemandStat()doublegetDeviationSumOfSquares()Gets the sum of squares of the deviations from the average This is the numerator in the classic sample variance formuladoublegetHalfWidth()Gets the confidence interval half-width.doublegetHalfWidth(double alpha)Gets the confidence interval half-width.intgetId()double[]getIntervalBetweenNonZeroDemandsData()StatisticgetIntervalBetweenNonZeroDemandStat()double[]getIntervalBetweenZeroDemandsData()StatisticgetIntervalBetweenZeroDemandsStat()doublegetKurtosis()Gets the kurtosis of the datadoublegetLag1Correlation()Gets the lag-1 generate correlation of the unweighted observations.doublegetLag1Covariance()Gets the lag-1 generate covariance of the unweighted observations.doublegetLastValue()Gets the last observed data pointintgetLeadingDigitRule(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 SchmeiserdoublegetMax()Gets the maximum of the observations.doublegetMin()Gets the minimum of the observations.java.lang.StringgetName()Gets the name of the Statisticdouble[]getNonZeroDemandsData()StatisticgetNonZeroDemandStat()doublegetNumberMissing()When a data point having the value of (Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY) are presented it is excluded from the summary statistics and the number of missing points is noted.intgetNumTransactions()doublegetProbFailure()doublegetProbSuccess()doublegetProbSuccessAfterFailure()doublegetProbSuccessAfterSuccess()doublegetRelativeError()Returns the relative error: getStandardError() / getAverage()doublegetRelativeWidth()Returns the relative width of the default confidence interval: 2.0 * getHalfWidth() / getAverage()doublegetRelativeWidth(double level)Returns the relative width of the level of the confidence interval: 2.0 * getHalfWidth(level) / getAverage()doublegetSkewness()Gets the skewness of the datadoublegetStandardDeviation()Gets the sample standard deviation of the observations.doublegetStandardError()Gets the standard error of the observations.double[]getStatistics()Fills up an array with the statistics defined by this interface statistics[0] = getCount() statistics[1] = getAverage() statistics[2] = getStandardDeviation() statistics[3] = getStandardError() statistics[4] = getHalfWidth() statistics[5] = getConfidenceLevel() statistics[6] = getMin() statistics[7] = getMax() statistics[8] = getSum() statistics[9] = getVariance() statistics[10] = getDeviationSumOfSquares() statistics[11] = getLastValue() statistics[12] = getKurtosis() statistics[13] = getSkewness() statistics[14] = getLag1Covariance() statistics[15] = getLag1Correlation() statistics[16] = getVonNeumannLag1TestStatistic() statistics[17] = getNumberMissing()doublegetSum()Gets the sum of the observations.doublegetVariance()Gets the sample variance of the observations.doublegetVonNeumannLag1TestStatistic()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.doublegetVonNeumannLag1TestStatisticPValue()Returns the asymptotic p-value for the Von Nueumann Lag-1 Test Statistic:voidreset()protected voidsetId()voidsetName(java.lang.String str)voidsetSaveDataOption(boolean flag)voidupdate(java.lang.Object o, java.lang.Object arg)This method is called when the observable needs observing-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsl.utilities.statistic.StatisticAccessorIfc
getCSVHeader, getCSVValues, getStatisticsAsMap, toString
-
-
-
-
Method Detail
-
reset
public void reset()
-
setSaveDataOption
public void setSaveDataOption(boolean flag)
-
setId
protected void setId()
-
setName
public final void setName(java.lang.String str)
-
getName
public java.lang.String getName()
Description copied from interface:StatisticAccessorIfcGets the name of the Statistic- Specified by:
getNamein interfaceGetNameIfc- Specified by:
getNamein interfaceStatisticAccessorIfc- Returns:
- The name as a String
-
getId
public int getId()
- Specified by:
getIdin interfaceIdentityIfc- Returns:
- an int representing the id of the object
-
update
public void update(java.lang.Object o, java.lang.Object arg)Description copied from interface:ObserverIfcThis method is called when the observable needs observing- Specified by:
updatein interfaceObserverIfc- Parameters:
o-arg-
-
collect
public void collect(double[] data)
-
collect
public void collect(double data)
-
getNonZeroDemandsData
public double[] getNonZeroDemandsData()
-
getDemandsData
public double[] getDemandsData()
-
getIntervalBetweenNonZeroDemandsData
public double[] getIntervalBetweenNonZeroDemandsData()
-
getIntervalBetweenZeroDemandsData
public double[] getIntervalBetweenZeroDemandsData()
-
getNumTransactions
public int getNumTransactions()
-
getIntervalBetweenNonZeroDemandStat
public Statistic getIntervalBetweenNonZeroDemandStat()
-
getIntervalBetweenZeroDemandsStat
public Statistic getIntervalBetweenZeroDemandsStat()
-
getNonZeroDemandStat
public Statistic getNonZeroDemandStat()
-
getDemandStat
public Statistic getDemandStat()
-
getProbSuccessAfterSuccess
public double getProbSuccessAfterSuccess()
-
getProbSuccessAfterFailure
public double getProbSuccessAfterFailure()
-
getProbSuccess
public double getProbSuccess()
-
getProbFailure
public double getProbFailure()
-
getAverage
public double getAverage()
Description copied from interface:StatisticAccessorIfcGets the unweighted average of the observations.- Specified by:
getAveragein interfaceStatisticAccessorIfc- Returns:
- A double representing the average or Double.NaN if no observations.
-
getConfidenceLevel
public double getConfidenceLevel()
Description copied from interface:StatisticAccessorIfcGets the confidence level. The default is given by Statistic.DEFAULT_CONFIDENCE_LEVEL = 0.95, which is a 95% confidence level- Specified by:
getConfidenceLevelin interfaceStatisticAccessorIfc- Returns:
- A double representing the confidence level
-
getCount
public double getCount()
Description copied from interface:StatisticAccessorIfcGets the count of the number of the observations.- Specified by:
getCountin interfaceStatisticAccessorIfc- Returns:
- A double representing the count
-
getDeviationSumOfSquares
public double getDeviationSumOfSquares()
Description copied from interface:StatisticAccessorIfcGets the sum of squares of the deviations from the average This is the numerator in the classic sample variance formula- Specified by:
getDeviationSumOfSquaresin interfaceStatisticAccessorIfc- Returns:
- A double representing the sum of squares of the deviations from the average
-
getHalfWidth
public double getHalfWidth(double alpha)
Description copied from interface:StatisticAccessorIfcGets the confidence interval half-width. Simply the generate standard error times the confidence coefficient as determined by an appropriate sampling distribution- Specified by:
getHalfWidthin interfaceStatisticAccessorIfc- Parameters:
alpha- the confidence level- Returns:
- A double representing the half-width or Double.NaN if < 1 observation
-
getHalfWidth
public double getHalfWidth()
Description copied from interface:StatisticAccessorIfcGets the confidence interval half-width. Simply the generate standard error times the confidence coefficient- Specified by:
getHalfWidthin interfaceStatisticAccessorIfc- Returns:
- A double representing the half-width or Double.NaN if < 1 observation
-
getConfidenceInterval
public Interval getConfidenceInterval(double alpha)
Description copied from interface:StatisticAccessorIfcA confidence interval for the mean based on the confidence level- Specified by:
getConfidenceIntervalin interfaceStatisticAccessorIfc- Parameters:
alpha- the confidence level- Returns:
- the interval
-
getConfidenceInterval
public Interval getConfidenceInterval()
Description copied from interface:StatisticAccessorIfcA confidence interval for the mean based on the confidence level- Specified by:
getConfidenceIntervalin interfaceStatisticAccessorIfc- Returns:
- the interval
-
getKurtosis
public double getKurtosis()
Description copied from interface:StatisticAccessorIfcGets the kurtosis of the data- Specified by:
getKurtosisin interfaceStatisticAccessorIfc- Returns:
- A double representing the kurtosis
-
getLag1Correlation
public double getLag1Correlation()
Description copied from interface:StatisticAccessorIfcGets the lag-1 generate correlation of the unweighted observations. Note: See Box, Jenkins, Reinsel, Time Series Analysis, 3rd edition, Prentice-Hall, pg 31- Specified by:
getLag1Correlationin interfaceStatisticAccessorIfc- Returns:
- A double representing the generate correlation or Double.NaN if <=2 observations
-
getLag1Covariance
public double getLag1Covariance()
Description copied from interface:StatisticAccessorIfcGets the lag-1 generate covariance of the unweighted observations. Note: See Box, Jenkins, Reinsel, Time Series Analysis, 3rd edition, Prentice-Hall, pg 31- Specified by:
getLag1Covariancein interfaceStatisticAccessorIfc- Returns:
- A double representing the generate covariance or Double.NaN if <=2 observations
-
getLastValue
public double getLastValue()
Description copied from interface:StatisticAccessorIfcGets the last observed data point- Specified by:
getLastValuein interfaceStatisticAccessorIfc- Returns:
- A double representing the last observations
-
getMax
public double getMax()
Description copied from interface:StatisticAccessorIfcGets the maximum of the observations.- Specified by:
getMaxin interfaceStatisticAccessorIfc- Returns:
- A double representing the maximum
-
getRelativeError
public double getRelativeError()
Description copied from interface:StatisticAccessorIfcReturns the relative error: getStandardError() / getAverage()- Specified by:
getRelativeErrorin interfaceStatisticAccessorIfc- Returns:
- the relative error
-
getRelativeWidth
public double getRelativeWidth()
Description copied from interface:StatisticAccessorIfcReturns the relative width of the default confidence interval: 2.0 * getHalfWidth() / getAverage()- Specified by:
getRelativeWidthin interfaceStatisticAccessorIfc- Returns:
- the relative width
-
getRelativeWidth
public double getRelativeWidth(double level)
Description copied from interface:StatisticAccessorIfcReturns the relative width of the level of the confidence interval: 2.0 * getHalfWidth(level) / getAverage()- Specified by:
getRelativeWidthin interfaceStatisticAccessorIfc- Parameters:
level- the confidence level- Returns:
- the relative width for the level
-
getMin
public double getMin()
Description copied from interface:StatisticAccessorIfcGets the minimum of the observations.- Specified by:
getMinin interfaceStatisticAccessorIfc- Returns:
- A double representing the minimum
-
getNumberMissing
public double getNumberMissing()
Description copied from interface:StatisticAccessorIfcWhen a data point having the value of (Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY) are presented it is excluded from the summary statistics and the number of missing points is noted. This method reports the number of missing points that occurred during the collection- Specified by:
getNumberMissingin interfaceStatisticAccessorIfc- Returns:
- the number missing
-
getSkewness
public double getSkewness()
Description copied from interface:StatisticAccessorIfcGets the skewness of the data- Specified by:
getSkewnessin interfaceStatisticAccessorIfc- Returns:
- A double representing the skewness
-
getStandardDeviation
public double getStandardDeviation()
Description copied from interface:StatisticAccessorIfcGets the sample standard deviation of the observations. Simply the square root of getVariance()- Specified by:
getStandardDeviationin interfaceStatisticAccessorIfc- Returns:
- A double representing the generate standard deviation or Double.NaN if 1 or less observations.
-
getStandardError
public double getStandardError()
Description copied from interface:StatisticAccessorIfcGets the standard error of the observations. Simply the generate standard deviation divided by the square root of the number of observations- Specified by:
getStandardErrorin interfaceStatisticAccessorIfc- Returns:
- A double representing the standard error or Double.NaN if < 1 observation
-
getLeadingDigitRule
public final int getLeadingDigitRule(double a)
Description copied from interface:StatisticAccessorIfcComputes 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- Specified by:
getLeadingDigitRulein interfaceStatisticAccessorIfc- Parameters:
a- the std error multiplier- Returns:
- the meaningful digit
-
getStatistics
public double[] getStatistics()
Description copied from interface:StatisticAccessorIfcFills up an array with the statistics defined by this interface statistics[0] = getCount() statistics[1] = getAverage() statistics[2] = getStandardDeviation() statistics[3] = getStandardError() statistics[4] = getHalfWidth() statistics[5] = getConfidenceLevel() statistics[6] = getMin() statistics[7] = getMax() statistics[8] = getSum() statistics[9] = getVariance() statistics[10] = getDeviationSumOfSquares() statistics[11] = getLastValue() statistics[12] = getKurtosis() statistics[13] = getSkewness() statistics[14] = getLag1Covariance() statistics[15] = getLag1Correlation() statistics[16] = getVonNeumannLag1TestStatistic() statistics[17] = getNumberMissing()- Specified by:
getStatisticsin interfaceStatisticAccessorIfc- Returns:
- an array of values
-
getSum
public double getSum()
Description copied from interface:StatisticAccessorIfcGets the sum of the observations.- Specified by:
getSumin interfaceStatisticAccessorIfc- Returns:
- A double representing the unweighted sum
-
getVariance
public double getVariance()
Description copied from interface:StatisticAccessorIfcGets the sample variance of the observations.- Specified by:
getVariancein interfaceStatisticAccessorIfc- Returns:
- A double representing the generate variance or Double.NaN if 1 or less observations.
-
getVonNeumannLag1TestStatistic
public double getVonNeumannLag1TestStatistic()
Description copied from interface:StatisticAccessorIfcGets 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.- Specified by:
getVonNeumannLag1TestStatisticin interfaceStatisticAccessorIfc- Returns:
- A double representing the Von Neumann test statistic
-
getVonNeumannLag1TestStatisticPValue
public final double getVonNeumannLag1TestStatisticPValue()
Description copied from interface:StatisticAccessorIfcReturns the asymptotic p-value for the Von Nueumann Lag-1 Test Statistic:Normal.stdNormalComplementaryCDF(getVonNeumannLag1TestStatistic());
- Specified by:
getVonNeumannLag1TestStatisticPValuein interfaceStatisticAccessorIfc- Returns:
- the p-value
-
getCSVStatistic
public java.lang.String getCSVStatistic()
NOT IMPLEMENTED YET- Specified by:
getCSVStatisticin interfaceGetCSVStatisticIfc- Specified by:
getCSVStatisticin interfaceStatisticAccessorIfc- Returns:
-
getCSVStatisticHeader
public java.lang.String getCSVStatisticHeader()
NOT IMPLEMENTED YET- Specified by:
getCSVStatisticHeaderin interfaceGetCSVStatisticIfc- Specified by:
getCSVStatisticHeaderin interfaceStatisticAccessorIfc- Returns:
-
-