コード例 #1
0
 public void update(double x) {
   if (x < minValue) minValue = x;
   if (x > maxValue) maxValue = x;
   sumValue += lastValue * (Sim.time() - lastTime);
   sumSquares += lastValue * lastValue * (Sim.time() - lastTime);
   lastValue = x;
   lastTime = Sim.time();
 }
コード例 #2
0
  public void report() {
    System.out.println("REPORT on Accumulate stat. collector ==> " + descriptor);
    /*    System.out.println ("      from time   to time       min         max         average");
    Num.printD (initTime, 12, 2, 2);
    Num.printD (Sim.time(), 13, 2, 2);
    Num.printD (minValue, 11, 3, 2);
    Num.printD ((double)maxValue, 12, 3, 2);
    Num.printD ((double)average(), 14, 3, 2);*/
    String[] myheads = {
      "      from time   to time        min         max      average",
      "      =========   =========     ======     ======    ========="
    };
    String[] linefmt1 = {"      ******.**   ******.**     ****.**    ****.**    ****.**"};
    printThus.printthus(myheads);
    Object[] lineval1 = {
      new Double(initTime),
      new Double(Sim.time()),
      new Double(minValue),
      new Double(maxValue),
      new Double((double) average())
    };
    int ierr = printThus.printthus(linefmt1, lineval1); // simple test

    System.out.println("\n");
  }
コード例 #3
0
 public double variance() {
   update(lastValue);
   double periode = Sim.time() - initTime;
   double temp = sumSquares / periode - (sumValue * sumValue);
   if ((periode > 0.0) && (temp > 0.0)) return temp;
   else return 0.0;
 } // added ANA
コード例 #4
0
 public void init() {
   maxValue = Double.MIN_VALUE;
   minValue = Double.MAX_VALUE;
   lastValue = 0.0;
   sumValue = 0.0;
   sumSquares = 0.0; // added
   initTime = lastTime = Sim.time();
 }
コード例 #5
0
 public double average() {
   update(lastValue);
   double periode = Sim.time() - initTime;
   if (periode > 0.0) return sumValue / periode;
   else return 0.0;
 }