Class NewDynamicDataAnalyzer
java.lang.Object
dataAnalysis.NewDynamicDataAnalyzer
- All Implemented Interfaces:
DynamicDataAnalyzer
Title: New Dynamic Data Analyzer Class
Description: Dynamic data analyzer of the JSIM engine. Simulation results are analyzed online with transient detection and confidence interval estimation: the transient period is removed with the R5 heuristic [Fis73] checked by the MSER-5 stationarity rule [Spr98], and the confidence intervals are then generated with the spectral method [HW81], as described in the JSIM chapters of the JMT user manual.
- Author:
- Bertoli Marco (Fisman rule), Omini Stefano (null test), Granata Federico (spectral test) Date: 11-gen-2006 Time: 12.02.04
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleconstant chosen to reduce bias of variance estimatorprotected intdegrees of freedom of the t-distributionprotected doublethe estimated confidence intervalsprotected booleantells if estimated confidence interval is okayprotected booleanprotected doublethe estimated meanprotected doublethe estimated varianceprotected intnumber of points of the polyfitprotected intthe order of the polynomial -
Constructor Summary
ConstructorsConstructorDescriptionNewDynamicDataAnalyzer(double alpha, double precision, int maxData) Creates a new Dynamic Data Analyzer -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddSample(double newSample, double weight) Adds the new sample to the statistic.protected voidupdates the conf intervalsdouble[]calcConstants(int K, int polyOrder) computes the degrees of freedom of the tStudent distribution used in the estimation of variance and confidence intervals C2, and a constant used to depolarize the variance estimatorprotected doublecalcEstimatorVar(int K, int polyOrder) computes the variance of the estimator of the varianceprotected voidcalcVar()updates the variancedoublecalcVar(double[] data, int start, int n, int K, int polyOrder) calculates the variance through Heidelberger & Welch method, if the data are the means of batches of size batchLen, the variance must be multiplied by batchLen.protected booleanApply the heuristic rule MSR5 to discard the most biased samples of the time series.doubleGets the estimated mean, even if the confidence requirements have not been reacheddoublegetAlfa()Gets measure alpha (i.e.doubleGets the half width confidence interval estimated of the monitored data stream.intGets the number of discarded datadoubleThis method return inverse of the instantaneous valueintGets the maximum number of samples that can be analyzeddoublegetMean()Gets the mean estimate of the monitored data streamdoubleThis method should be called only if mean is equal to zero (@see isZero()), that is when nullTest() returns true.doubleGets measure precision (i.e.intGets number of samples elaborated up to nowbooleanReturns if the analysis was successfulprotected booleanHWtest()Applies the spectral test to generate the Confidence Intervals.booleanisZero()Returns true if null test has found out that this measure is zeroprotected booleannullTest()Verifies whether the measure is almost always equal to zerovoidsetParameters(SimParameters parameters) Sets the reference to the class containing simulation parameters.voidstopMeasure(boolean success) Stops the measuring process
-
Field Details
-
extMean
protected double extMeanthe estimated mean -
extVar
protected double extVarthe estimated variance -
confInt
protected double confIntthe estimated confidence intervals -
C1
protected double C1constant chosen to reduce bias of variance estimator -
C2
protected int C2degrees of freedom of the t-distribution -
K
protected int Knumber of points of the polyfit -
polyOrder
protected int polyOrderthe order of the polynomial -
confIntervalOk
protected boolean confIntervalOktells if estimated confidence interval is okay -
disableStatisticStop
protected boolean disableStatisticStop
-
-
Constructor Details
-
NewDynamicDataAnalyzer
public NewDynamicDataAnalyzer(double alpha, double precision, int maxData) Creates a new Dynamic Data Analyzer- Parameters:
alpha- the quantile required for the confidence intervalprecision- maximum relative errormaxData- maximum number of data to be analyzed (at least QueueNet.SimulationDefaults.MAX_RULE_SAMPLES)
-
-
Method Details
-
addSample
public boolean addSample(double newSample, double weight) Adds the new sample to the statistic.- Specified by:
addSamplein interfaceDynamicDataAnalyzer- Parameters:
newSample- the new sampleweight- the weight of the newSample, if it is not needed put 1.- Returns:
- true if the computation of confidence interval has finished (i.e. if the confidence interval is smaller than the one required by the user, or if the analyzed data are too many), false otherwise
-
getLastIntervalAvg
public double getLastIntervalAvg()Description copied from interface:DynamicDataAnalyzerThis method return inverse of the instantaneous value- Specified by:
getLastIntervalAvgin interfaceDynamicDataAnalyzer
-
HWtest
protected boolean HWtest()Applies the spectral test to generate the Confidence Intervals.
See:
P. Heidelberger,Peter D. Welch
"A spectral method for confidence interval generation and run length control in simulations"- Returns:
- true if the precision requirement is reached. false if not.
-
calcConfInterval
protected void calcConfInterval()updates the conf intervals -
calcVar
protected void calcVar()updates the variance -
calcVar
public double calcVar(double[] data, int start, int n, int K, int polyOrder) calculates the variance through Heidelberger & Welch method, if the data are the means of batches of size batchLen, the variance must be multiplied by batchLen.- Parameters:
data- array containing the sequence of datastart- the starting samplen- number of data of the sequence to be estimatedK- number of points used in the polynomial fitting must be <= n/4, typically is 25, 50polyOrder- the order of the polynomial to be fitted to the getLog of the spectrum of data typically is 2 or 3.- Returns:
- the estimated variance
-
calcConstants
public double[] calcConstants(int K, int polyOrder) computes the degrees of freedom of the tStudent distribution used in the estimation of variance and confidence intervals C2, and a constant used to depolarize the variance estimator- Parameters:
K- number of points of the polyfitpolyOrder- the order of the polynomial- Returns:
- the double array of dimension 2, at first position it is C1 and at second C2
-
calcEstimatorVar
protected double calcEstimatorVar(int K, int polyOrder) computes the variance of the estimator of the variance -
deleteTransient
protected boolean deleteTransient()Apply the heuristic rule MSR5 to discard the most biased samples of the time series. It minimizes the Mean Square Error. -
nullTest
protected boolean nullTest()Verifies whether the measure is almost always equal to zero- Returns:
- true if the measure is almost always equal to zero
-
getSuccess
public boolean getSuccess()Returns if the analysis was successful- Specified by:
getSuccessin interfaceDynamicDataAnalyzer- Returns:
- true if the analysis respect all'users requests
-
getMean
public double getMean()Gets the mean estimate of the monitored data stream- Specified by:
getMeanin interfaceDynamicDataAnalyzer- Returns:
- mean estimate of the monitored data stream
-
estimatedMean
public double estimatedMean()Gets the estimated mean, even if the confidence requirements have not been reached- Specified by:
estimatedMeanin interfaceDynamicDataAnalyzer- Returns:
- the estimated mean
-
isZero
public boolean isZero()Returns true if null test has found out that this measure is zero- Specified by:
isZeroin interfaceDynamicDataAnalyzer- Returns:
- true if null test has found out that this measure is zero
-
getConfInt
public double getConfInt()Gets the half width confidence interval estimated of the monitored data stream.- Specified by:
getConfIntin interfaceDynamicDataAnalyzer- Returns:
- the confidence interval requested
-
getNullMeasure_upperLimit
public double getNullMeasure_upperLimit()This method should be called only if mean is equal to zero (@see isZero()), that is when nullTest() returns true.- Specified by:
getNullMeasure_upperLimitin interfaceDynamicDataAnalyzer- Returns:
- the upper limit of confidence interval when mean is equal to 0.0
-
getSamples
public int getSamples()Gets number of samples elaborated up to now- Specified by:
getSamplesin interfaceDynamicDataAnalyzer- Returns:
- number of samples elaborated
-
getDiscarded
public int getDiscarded()Gets the number of discarded data- Specified by:
getDiscardedin interfaceDynamicDataAnalyzer- Returns:
- the number of discarded data
-
getMaxData
public int getMaxData()Gets the maximum number of samples that can be analyzed- Specified by:
getMaxDatain interfaceDynamicDataAnalyzer- Returns:
- maximum number of samples that can be analyzed
-
getPrecision
public double getPrecision()Gets measure precision (i.e. Maximum relative error)- Specified by:
getPrecisionin interfaceDynamicDataAnalyzer- Returns:
- precision value
-
getAlfa
public double getAlfa()Gets measure alpha (i.e. confidence interval)- Specified by:
getAlfain interfaceDynamicDataAnalyzer- Returns:
- alpha value
-
stopMeasure
public void stopMeasure(boolean success) Stops the measuring process- Specified by:
stopMeasurein interfaceDynamicDataAnalyzer- Parameters:
success- value to be reported by getSuccess()
-
setParameters
Sets the reference to the class containing simulation parameters. The parameters are updated with the passed values.- Specified by:
setParametersin interfaceDynamicDataAnalyzer- Parameters:
parameters-
-