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 void
collect(double data)
void
collect(double[] data)
double
getAverage()
Gets the unweighted average of the observations.Interval
getConfidenceInterval()
A confidence interval for the mean based on the confidence levelInterval
getConfidenceInterval(double alpha)
A confidence interval for the mean based on the confidence leveldouble
getConfidenceLevel()
Gets the confidence level.double
getCount()
Gets the count of the number of the observations.java.lang.String
getCSVStatistic()
NOT IMPLEMENTED YETjava.lang.String
getCSVStatisticHeader()
NOT IMPLEMENTED YETdouble[]
getDemandsData()
Statistic
getDemandStat()
double
getDeviationSumOfSquares()
Gets the sum of squares of the deviations from the average This is the numerator in the classic sample variance formuladouble
getHalfWidth()
Gets the confidence interval half-width.double
getHalfWidth(double alpha)
Gets the confidence interval half-width.int
getId()
double[]
getIntervalBetweenNonZeroDemandsData()
Statistic
getIntervalBetweenNonZeroDemandStat()
double[]
getIntervalBetweenZeroDemandsData()
Statistic
getIntervalBetweenZeroDemandsStat()
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.java.lang.String
getName()
Gets the name of the Statisticdouble[]
getNonZeroDemandsData()
Statistic
getNonZeroDemandStat()
double
getNumberMissing()
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.int
getNumTransactions()
double
getProbFailure()
double
getProbSuccess()
double
getProbSuccessAfterFailure()
double
getProbSuccessAfterSuccess()
double
getRelativeError()
Returns the relative error: getStandardError() / getAverage()double
getRelativeWidth()
Returns the relative width of the default confidence interval: 2.0 * getHalfWidth() / getAverage()double
getRelativeWidth(double level)
Returns the relative width of the level of the confidence interval: 2.0 * getHalfWidth(level) / getAverage()double
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[]
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()double
getSum()
Gets the sum of the observations.double
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:void
reset()
protected void
setId()
void
setName(java.lang.String str)
void
setSaveDataOption(boolean flag)
void
update(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:StatisticAccessorIfc
Gets the name of the Statistic- Specified by:
getName
in interfaceGetNameIfc
- Specified by:
getName
in interfaceStatisticAccessorIfc
- Returns:
- The name as a String
-
getId
public int getId()
- Specified by:
getId
in 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:ObserverIfc
This method is called when the observable needs observing- Specified by:
update
in 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:StatisticAccessorIfc
Gets the unweighted average of the observations.- Specified by:
getAverage
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the average or Double.NaN if no observations.
-
getConfidenceLevel
public double getConfidenceLevel()
Description copied from interface:StatisticAccessorIfc
Gets the confidence level. The default is given by Statistic.DEFAULT_CONFIDENCE_LEVEL = 0.95, which is a 95% confidence level- Specified by:
getConfidenceLevel
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the confidence level
-
getCount
public double getCount()
Description copied from interface:StatisticAccessorIfc
Gets the count of the number of the observations.- Specified by:
getCount
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the count
-
getDeviationSumOfSquares
public 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- Specified by:
getDeviationSumOfSquares
in 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:StatisticAccessorIfc
Gets the confidence interval half-width. Simply the generate standard error times the confidence coefficient as determined by an appropriate sampling distribution- Specified by:
getHalfWidth
in 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:StatisticAccessorIfc
Gets the confidence interval half-width. Simply the generate standard error times the confidence coefficient- Specified by:
getHalfWidth
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the half-width or Double.NaN if < 1 observation
-
getConfidenceInterval
public Interval getConfidenceInterval(double alpha)
Description copied from interface:StatisticAccessorIfc
A confidence interval for the mean based on the confidence level- Specified by:
getConfidenceInterval
in interfaceStatisticAccessorIfc
- Parameters:
alpha
- the confidence level- Returns:
- the interval
-
getConfidenceInterval
public Interval getConfidenceInterval()
Description copied from interface:StatisticAccessorIfc
A confidence interval for the mean based on the confidence level- Specified by:
getConfidenceInterval
in interfaceStatisticAccessorIfc
- Returns:
- the interval
-
getKurtosis
public double getKurtosis()
Description copied from interface:StatisticAccessorIfc
Gets the kurtosis of the data- Specified by:
getKurtosis
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the kurtosis
-
getLag1Correlation
public 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- Specified by:
getLag1Correlation
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the generate correlation or Double.NaN if <=2 observations
-
getLag1Covariance
public 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- Specified by:
getLag1Covariance
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the generate covariance or Double.NaN if <=2 observations
-
getLastValue
public double getLastValue()
Description copied from interface:StatisticAccessorIfc
Gets the last observed data point- Specified by:
getLastValue
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the last observations
-
getMax
public double getMax()
Description copied from interface:StatisticAccessorIfc
Gets the maximum of the observations.- Specified by:
getMax
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the maximum
-
getRelativeError
public double getRelativeError()
Description copied from interface:StatisticAccessorIfc
Returns the relative error: getStandardError() / getAverage()- Specified by:
getRelativeError
in interfaceStatisticAccessorIfc
- Returns:
- the relative error
-
getRelativeWidth
public double getRelativeWidth()
Description copied from interface:StatisticAccessorIfc
Returns the relative width of the default confidence interval: 2.0 * getHalfWidth() / getAverage()- Specified by:
getRelativeWidth
in interfaceStatisticAccessorIfc
- Returns:
- the relative width
-
getRelativeWidth
public double getRelativeWidth(double level)
Description copied from interface:StatisticAccessorIfc
Returns the relative width of the level of the confidence interval: 2.0 * getHalfWidth(level) / getAverage()- Specified by:
getRelativeWidth
in interfaceStatisticAccessorIfc
- Parameters:
level
- the confidence level- Returns:
- the relative width for the level
-
getMin
public double getMin()
Description copied from interface:StatisticAccessorIfc
Gets the minimum of the observations.- Specified by:
getMin
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the minimum
-
getNumberMissing
public double getNumberMissing()
Description copied from interface:StatisticAccessorIfc
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. This method reports the number of missing points that occurred during the collection- Specified by:
getNumberMissing
in interfaceStatisticAccessorIfc
- Returns:
- the number missing
-
getSkewness
public double getSkewness()
Description copied from interface:StatisticAccessorIfc
Gets the skewness of the data- Specified by:
getSkewness
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the skewness
-
getStandardDeviation
public double getStandardDeviation()
Description copied from interface:StatisticAccessorIfc
Gets the sample standard deviation of the observations. Simply the square root of getVariance()- Specified by:
getStandardDeviation
in 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:StatisticAccessorIfc
Gets the standard error of the observations. Simply the generate standard deviation divided by the square root of the number of observations- Specified by:
getStandardError
in 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: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- Specified by:
getLeadingDigitRule
in interfaceStatisticAccessorIfc
- Parameters:
a
- the std error multiplier- Returns:
- the meaningful digit
-
getStatistics
public double[] getStatistics()
Description copied from interface:StatisticAccessorIfc
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()- Specified by:
getStatistics
in interfaceStatisticAccessorIfc
- Returns:
- an array of values
-
getSum
public double getSum()
Description copied from interface:StatisticAccessorIfc
Gets the sum of the observations.- Specified by:
getSum
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the unweighted sum
-
getVariance
public double getVariance()
Description copied from interface:StatisticAccessorIfc
Gets the sample variance of the observations.- Specified by:
getVariance
in interfaceStatisticAccessorIfc
- Returns:
- A double representing the generate variance or Double.NaN if 1 or less observations.
-
getVonNeumannLag1TestStatistic
public 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.- Specified by:
getVonNeumannLag1TestStatistic
in interfaceStatisticAccessorIfc
- 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());
- Specified by:
getVonNeumannLag1TestStatisticPValue
in interfaceStatisticAccessorIfc
- Returns:
- the p-value
-
getCSVStatistic
public java.lang.String getCSVStatistic()
NOT IMPLEMENTED YET- Specified by:
getCSVStatistic
in interfaceGetCSVStatisticIfc
- Specified by:
getCSVStatistic
in interfaceStatisticAccessorIfc
- Returns:
-
getCSVStatisticHeader
public java.lang.String getCSVStatisticHeader()
NOT IMPLEMENTED YET- Specified by:
getCSVStatisticHeader
in interfaceGetCSVStatisticIfc
- Specified by:
getCSVStatisticHeader
in interfaceStatisticAccessorIfc
- Returns:
-
-