Package umontreal.iro.lecuyer.stat

Examples of umontreal.iro.lecuyer.stat.Tally


      public Tally      statSojourn; // Stats on sojourn times.

      // Reads data for new task type and creates data structures.
      TaskType() throws IOException {
         StringTokenizer line = new StringTokenizer (input.readLine());
         statSojourn = new Tally (name = line.nextToken());
         arrivalRate = Double.parseDouble (line.nextToken());
         nbOper = Integer.parseInt (line.nextToken());
         machOper = new Resource[nbOper];
         lengthOper = new double[nbOper];
         for (int i = 0; i < nbOper; i++) {
View Full Code Here


      int s = 12;
      double[] zeta = new double[s+1];   zeta[0] = 0.0;
      for (int j=1; j<=s; j++)
         zeta[j] = (double)j / (double)s;
      Asian process = new Asian (0.05, 0.5, 100.0, 100.0, s, zeta);
      Tally statValue = new Tally ("Stats on value of Asian option");

      Chrono timer = new Chrono();
      int n = 100000;
      process.simulateRuns (n, new MRG32k3a(), statValue);
      statValue.setConfidenceIntervalStudent();
      System.out.println (statValue.report (0.95, 3));
      System.out.println ("Total CPU time:      " + timer.format() + "\n");
   }
View Full Code Here

   // Makes m independent randomizations of the digital net p using stream
   // noise. For each of them, performs one simulation run for each point
   // of p, and adds the average over these points to the collector statQMC.
   public void simulateQMC (int m, PointSet p,
                            RandomStream noise, Tally statQMC) {
      Tally statValue  = new Tally ("stat on value of Asian option");
      PointSetIterator stream = p.iterator ();
      for (int j=0; j<m; j++) {
          p.randomize (noise);
          stream.resetStartStream();
          simulateRuns (p.getNumPoints(), stream, statValue);
          statQMC.add (statValue.average());
      }
   }
View Full Code Here

      int s = 12;
      double[] zeta = new double[s+1];
      for (int j=0; j<=s; j++)
         zeta[j] = (double)j / (double)s;
      AsianQMCk process = new AsianQMCk (0.05, 0.5, 100.0, 100.0, s, zeta);
      Tally statValue  = new Tally ("value of Asian option");
      Tally statQMC = new Tally ("QMC averages for Asian option");

      Chrono timer = new Chrono();
      int n = 100000;
      System.out.println ("Ordinary MC:\n");
      process.simulateRuns (n, new MRG32k3a(), statValue);
      statValue.setConfidenceIntervalStudent();
      System.out.println (statValue.report (0.95, 3));
      System.out.println ("Total CPU time: " + timer.format());
      double varMC = statValue.variance();
      double cpuMC = timer.getSeconds() / n;  // CPU seconds per run.
      System.out.println ("------------------------\n");

      timer.init();
      KorobovLattice p = new KorobovLattice (65521, 944, s); // approx. 2^{16} points.
      BakerTransformedPointSet pb = new BakerTransformedPointSet (p);

      n = p.getNumPoints();
      int m = 20;                     // Number of QMC randomizations.
      process.simulateQMC (m, pb, new MRG32k3a(), statQMC);
      System.out.println ("QMC with Korobov point set with " + n +
          " points and random shift + baker:\n");
      statQMC.setConfidenceIntervalStudent();
      System.out.println (statQMC.report (0.95, 3));
      System.out.println ("Total CPU time: " + timer.format() + "\n");
      double varQMC = p.getNumPoints() * statQMC.variance();
      double cpuQMC = timer.getSeconds() / (m * n);
      System.out.printf ("Variance ratio:   %9.4g%n", varMC/varQMC);
      System.out.printf ("Efficiency ratio: %9.4g%n",
           (varMC * cpuMC) / (varQMC * cpuQMC));
   }
View Full Code Here

  public void setStatCollecting (boolean b) {
    if (b && !stats) {
      if (blockSize == null)
      blockSize = new Accumulate(sim, "List Size " + name);
      if (blockSojourn == null)
      blockSojourn = new Tally("List Sojourn " + name);
      blockSize.update (size());
      stats = true;
      initStat();
    } else
    stats = false;
View Full Code Here

    if (statAvail == null) throw new IllegalStateException ("Asking a report for a bin "
                          +"for which setStatCollecting (true) has not been called");

    Accumulate sizeWait = waitingList.statSize();
    Tally sojWait = waitingList.statSojourn();

    PrintfFormat str = new PrintfFormat();

    str.append ("REPORT ON BIN : ").append (name).append (PrintfFormat.NEWLINE);
    str.append ("   From time : ").append (7, 2, 2, initStatTime);
    str.append ("   to time : ");
    str.append (10,2, 2, sim.time());
    str.append (PrintfFormat.NEWLINE + "                    min        max     average  ");
    str.append ("standard dev.  nb. obs.");

    str.append (PrintfFormat.NEWLINE + "   Available tokens ");
    str.append (8, (int)(statAvail.min()+0.5));
    str.append (11, (int)(statAvail.max()+0.5));
    str.append (12, 3, 2, statAvail.average());

    str.append (PrintfFormat.NEWLINE + "   Queue Size  ");
    str.append (8, (int)(sizeWait.min()+0.5));
    str.append (11, (int)(sizeWait.max()+0.5));
    str.append (12, 3, 2, sizeWait.average());

    str.append (PrintfFormat.NEWLINE + "   Wait    ");
    str.append (12, 3, 2, sojWait.min()).append (' ');
    str.append (10, 3, 2, sojWait.max()).append (' ');
    str.append (11, 3, 2, sojWait.average()).append (' ');
    str.append (10, 3, 2, sojWait.standardDeviation());
    str.append (10, sojWait.numberObs());

    return str.toString();
   }
View Full Code Here

  new ProcGenArr().schedule (0.0);
  Sim.start();
    }

    public Cafeteria(){
  AttClient[Hotfood= new Tally("Temps d'attente repas chauds");
  AttClient[Sandwich] = new Tally("Temps d'attente sandwich");
  AttClient[Drinks]   = new Tally("Temps d'attente breuvages");
  for (int i=0; i<3; i++) {
      Caisse[i] = new Resource (1, "Une caisse");
      Caisse[i].setStatCollecting (true);
  }
  HotServ.setStatCollecting (true);
View Full Code Here

   // Makes m independent randomizations of the digital net p using stream
   // noise. For each of them, performs one simulation run for each point
   // of p, and adds the average over these points to the collector statQMC.
   public void simulateQMC (int m, DigitalNet p,
                            RandomStream noise, Tally statQMC) {
      Tally statValue  = new Tally ("stat on value of Asian option");
      PointSetIterator stream = p.iterator ();
      for (int j=0; j<m; j++) {
          p.leftMatrixScramble (noise);
          p.addRandomShift (0, p.getDimension(), noise);
          stream.resetStartStream();
          simulateRuns (p.getNumPoints(), stream, statValue);
          statQMC.add (statValue.average());
      }
   }
View Full Code Here

      int s = 12;
      double[] zeta = new double[s+1];
      for (int j=0; j<=s; j++)
         zeta[j] = (double)j / (double)s;
      AsianQMC process = new AsianQMC (0.05, 0.5, 100.0, 100.0, s, zeta);
      Tally statValue  = new Tally ("value of Asian option");
      Tally statQMC = new Tally ("QMC averages for Asian option");

      Chrono timer = new Chrono();
      int n = 100000;
      System.out.println ("Ordinary MC:\n");
      process.simulateRuns (n, new MRG32k3a(), statValue);
      statValue.setConfidenceIntervalStudent();
      System.out.println (statValue.report (0.95, 3));
      System.out.println ("Total CPU time: " + timer.format());
      double varMC = statValue.variance();
      double cpuMC = timer.getSeconds() / n;  // CPU seconds per run.
      System.out.println ("------------------------\n");

      timer.init();
      DigitalNet p = new SobolSequence (16, 31, s); // 2^{16} points.
      n = p.getNumPoints();
      int m = 20;                     // Number of QMC randomizations.
      process.simulateQMC (m, p, new MRG32k3a(), statQMC);
      System.out.println ("QMC with Sobol point set with " + n +
          " points and affine matrix scramble:\n");
      statQMC.setConfidenceIntervalStudent();
      System.out.println (statQMC.report (0.95, 3));
      System.out.println ("Total CPU time: " + timer.format() + "\n");
      double varQMC = p.getNumPoints() * statQMC.variance();
      double cpuQMC = timer.getSeconds() / (m * n);
      System.out.printf ("Variance ratio:   %9.4g%n", varMC/varQMC);
      System.out.printf ("Efficiency ratio: %9.4g%n",
           (varMC * cpuMC) / (varQMC * cpuQMC));
   }
View Full Code Here

         else {
            statUtil = new Accumulate (sim, "StatOnUtil");
            statUtil.update (capacity - available);
            statCapacity = new Accumulate (sim, "StatOnCapacity");
            statCapacity.update (capacity);
            statSojourn = new Tally ("StatOnSojourn");
         }
      }
      else {
         if (stats)
           throw new IllegalStateException ("Not collecting statistics for this resource");
View Full Code Here

TOP

Related Classes of umontreal.iro.lecuyer.stat.Tally

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.