Class NewDynamicDataAnalyzer

java.lang.Object
dataAnalysis.NewDynamicDataAnalyzer
All Implemented Interfaces:
DynamicDataAnalyzer

public class NewDynamicDataAnalyzer extends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    protected double
    constant chosen to reduce bias of variance estimator
    protected int
    degrees of freedom of the t-distribution
    protected double
    the estimated confidence intervals
    protected boolean
    tells if estimated confidence interval is okay
    protected boolean
     
    protected double
    the estimated mean
    protected double
    the estimated variance
    protected int
    number of points of the polyfit
    protected int
    the order of the polynomial
  • Constructor Summary

    Constructors
    Constructor
    Description
    NewDynamicDataAnalyzer(double alpha, double precision, int maxData)
    Creates a new Dynamic Data Analyzer
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    addSample(double newSample, double weight)
    Adds the new sample to the statistic.
    protected void
    updates the conf intervals
    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
    protected double
    calcEstimatorVar(int K, int polyOrder)
    computes the variance of the estimator of the variance
    protected void
    updates the variance
    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.
    protected boolean
    Apply the heuristic rule MSR5 to discard the most biased samples of the time series.
    double
    Gets the estimated mean, even if the confidence requirements have not been reached
    double
    Gets measure alpha (i.e.
    double
    Gets the half width confidence interval estimated of the monitored data stream.
    int
    Gets the number of discarded data
    double
    This method return inverse of the instantaneous value
    int
    Gets the maximum number of samples that can be analyzed
    double
    Gets the mean estimate of the monitored data stream
    double
    This method should be called only if mean is equal to zero (@see isZero()), that is when nullTest() returns true.
    double
    Gets measure precision (i.e.
    int
    Gets number of samples elaborated up to now
    boolean
    Returns if the analysis was successful
    protected boolean
    Applies the spectral test to generate the Confidence Intervals.
    boolean
    Returns true if null test has found out that this measure is zero
    protected boolean
    Verifies whether the measure is almost always equal to zero
    void
    Sets the reference to the class containing simulation parameters.
    void
    stopMeasure(boolean success)
    Stops the measuring process

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • extMean

      protected double extMean
      the estimated mean
    • extVar

      protected double extVar
      the estimated variance
    • confInt

      protected double confInt
      the estimated confidence intervals
    • C1

      protected double C1
      constant chosen to reduce bias of variance estimator
    • C2

      protected int C2
      degrees of freedom of the t-distribution
    • K

      protected int K
      number of points of the polyfit
    • polyOrder

      protected int polyOrder
      the order of the polynomial
    • confIntervalOk

      protected boolean confIntervalOk
      tells 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 interval
      precision - maximum relative error
      maxData - 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:
      addSample in interface DynamicDataAnalyzer
      Parameters:
      newSample - the new sample
      weight - 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: DynamicDataAnalyzer
      This method return inverse of the instantaneous value
      Specified by:
      getLastIntervalAvg in interface DynamicDataAnalyzer
    • 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 data
      start - the starting sample
      n - number of data of the sequence to be estimated
      K - number of points used in the polynomial fitting must be <= n/4, typically is 25, 50
      polyOrder - 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 polyfit
      polyOrder - 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:
      getSuccess in interface DynamicDataAnalyzer
      Returns:
      true if the analysis respect all'users requests
    • getMean

      public double getMean()
      Gets the mean estimate of the monitored data stream
      Specified by:
      getMean in interface DynamicDataAnalyzer
      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:
      estimatedMean in interface DynamicDataAnalyzer
      Returns:
      the estimated mean
    • isZero

      public boolean isZero()
      Returns true if null test has found out that this measure is zero
      Specified by:
      isZero in interface DynamicDataAnalyzer
      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:
      getConfInt in interface DynamicDataAnalyzer
      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_upperLimit in interface DynamicDataAnalyzer
      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:
      getSamples in interface DynamicDataAnalyzer
      Returns:
      number of samples elaborated
    • getDiscarded

      public int getDiscarded()
      Gets the number of discarded data
      Specified by:
      getDiscarded in interface DynamicDataAnalyzer
      Returns:
      the number of discarded data
    • getMaxData

      public int getMaxData()
      Gets the maximum number of samples that can be analyzed
      Specified by:
      getMaxData in interface DynamicDataAnalyzer
      Returns:
      maximum number of samples that can be analyzed
    • getPrecision

      public double getPrecision()
      Gets measure precision (i.e. Maximum relative error)
      Specified by:
      getPrecision in interface DynamicDataAnalyzer
      Returns:
      precision value
    • getAlfa

      public double getAlfa()
      Gets measure alpha (i.e. confidence interval)
      Specified by:
      getAlfa in interface DynamicDataAnalyzer
      Returns:
      alpha value
    • stopMeasure

      public void stopMeasure(boolean success)
      Stops the measuring process
      Specified by:
      stopMeasure in interface DynamicDataAnalyzer
      Parameters:
      success - value to be reported by getSuccess()
    • setParameters

      public void setParameters(SimParameters parameters)
      Sets the reference to the class containing simulation parameters. The parameters are updated with the passed values.
      Specified by:
      setParameters in interface DynamicDataAnalyzer
      Parameters:
      parameters -