Ejemplo n.º 1
0
  public static void main(String[] args) {

    double[] sigma = {3E-4, 1E-6, 2.4E-2, 6.67E-5, 1E-6, 6E-3, 4.4E-4, 1E-2, 1E-6};
    double[] mu = {0.42E9, 2.27};
    double alpha = 0.0;
    Sampler sampler = new Sampler(mu, sigma, alpha);
    double[][] M = sampler.getCovMat();
    System.out.println("The Covirance Matrix is:");
    sampler.printMatrix(M);

    double[][] A = sampler.getCholDecompA();
    System.out.println("The decomposed Matrix A is");
    sampler.printMatrix(A);

    try {

      File file = new File("/Users/Weizheng/Documents/JavaWorkPlace/CLS_MCIntegrator/output.txt");
      // if file doesnt exists, then create it
      if (!file.exists()) {
        file.createNewFile();
      } else {
        file.delete();
        file.createNewFile();
      }

      PrintWriter fw = new PrintWriter(file);

      long startTime = System.currentTimeMillis();

      for (int i = 0; i < 1E3; i++) {
        double[] MultiNormalVector = sampler.nextMultiNormalVector();
        //				for(double a:MultiNormalVector ){
        //					fw.printf("%4.2e ", a);
        //				}
        //				fw.println("");
      }
      fw.close();
      long endTime = System.currentTimeMillis();
      System.out.println("That took " + (endTime - startTime) + " milliseconds");

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
Archivo: Main.java Proyecto: YpGu/gcoev
  public static void main(String[] args) {
    if (args.length != 2) {
      System.out.println("Usage: java Main <seed> <delta>");
      System.exit(0);
    }
    String seed = args[0];
    delta_str = args[1];
    File f = new File("./res/" + seed + "_" + delta_str); // e.g. "./res/0_0.5/"
    f.mkdir();
    delta = Double.parseDouble(args[1]);
    //    lambda = Double.parseDouble(args[1]);

    test1(seed);
  }
Ejemplo n.º 3
0
      public void executePlay() {
        println("play");

        isPlaying = true;
        startTime = System.nanoTime();
      }
Ejemplo n.º 4
0
      public void update() {

        if (isPlaying) {
          // only plays sound for dialog
          if (sMan.eventHappened(getPosInSeconds())) {
            // put sound code here!!!
            sMan.peekNextEvent().execute(getPosInSeconds());
            println(sMan.popEvent());
          }

          // find if previous dialog should still be playing, and if so, play it
          if (sMan.getPreviousPoppedDialog(getPosInSeconds()) != null) {
            sMan.getPreviousPoppedDialog(getPosInSeconds()).execute(getPosInSeconds());
            //          println(sMan.getPreviousPoppedDialog(getPosInSeconds()));
          }
        }

        if (overSlide()) {
          over = true;
        } else {
          over = false;
        }

        if (mousePressed && over) {
          locked = true;
        }
        if (!mousePressed) {
          locked = false;
        }
        if (locked) {
          newspos = constrain(mouseX - sheight / 2, sposMin, sposMax);
        }

        if (abs(newspos - spos) > 1 || isPlaying) {

          // if playback has collided with the end of the timeline, stop playing
          if (isPlaying) {
            if (getPosInSeconds() >= totalTime) {
              executePause();
            }
          }

          if (isPlaying) {
            long estimatedTime = System.nanoTime() - startTime;

            if (estimatedTime / 1000000000 >= 1) {
              // if one second has passed, make a new start time (reset the second timer)
              startTime = System.nanoTime();
              //            println("before spos is " + spos + " time is " + getPosInSeconds());
              spos = incrementSposInSeconds();
              println(
                  "spos is "
                      + spos
                      + " time is "
                      + getPosInSeconds()
                      + " frame is "
                      + getPosInFrames());
            }

          } else {
            spos = spos + (newspos - spos) / loose;
          }
        }
        // if the timeline is NOT playing, create the queue for the events to unfold in order
        if (!isPlaying) {
          sMan.createQueue(getPosInSeconds());
        }
        //      println(getPosInSeconds());

      }