Example #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();
    }
  }