public String toString() {
    StringBuffer ret = new StringBuffer();

    ret.append("Index : " + index + "\n");
    ret.append("Mu : " + mu + "\n");
    ret.append("Omega : " + omega + "\n");
    /*for(int i=0; i<10; i++) {
    ret.append( "\n" );
    }*/

    return ret.toString();
  }
 String openUrlAsString(String address, int maxLines) {
   StringBuffer sb;
   try {
     URL url = new URL(address);
     InputStream in = url.openStream();
     BufferedReader br = new BufferedReader(new InputStreamReader(in));
     sb = new StringBuffer();
     int count = 0;
     String line;
     while ((line = br.readLine()) != null && count++ < maxLines) sb.append(line + "\n");
     in.close();
   } catch (IOException e) {
     sb = null;
   }
   return sb != null ? new String(sb) : null;
 }
 /** Returns a text file contained in ij.jar. */
 public String openFromIJJar(String path) {
   String text = null;
   try {
     InputStream is = this.getClass().getResourceAsStream(path);
     // IJ.log(is+"	"+path);
     if (is == null) return null;
     InputStreamReader isr = new InputStreamReader(is);
     StringBuffer sb = new StringBuffer();
     char[] b = new char[8192];
     int n;
     while ((n = isr.read(b)) > 0) sb.append(b, 0, n);
     text = sb.toString();
   } catch (IOException e) {
   }
   return text;
 }
 String open(String path) {
   if (path == null) return null;
   try {
     StringBuffer sb = new StringBuffer(5000);
     BufferedReader r = new BufferedReader(new FileReader(path));
     while (true) {
       String s = r.readLine();
       if (s == null) break;
       else sb.append(s + "\n");
     }
     r.close();
     return new String(sb);
   } catch (Exception e) {
     IJ.error(e.getMessage());
     return null;
   }
 }
 public boolean get_errors(double[] params, int[] fixes) {
   GenericDialog gd = new GenericDialog("Error Options");
   String[] methods = {"Support Plane", "Monte Carlo"};
   gd.addChoice("Method", methods, methods[0]);
   float conf = 0.67f;
   gd.addNumericField("SP_Confidence Limit (%)", (int) (conf * 100.0f), 5, 10, null);
   String[] labels = {"P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10"};
   gd.addChoice("SP_Parameter", labels, labels[0]);
   double spacing = 0.01;
   gd.addNumericField("SP_Chi^2_plot_spacing (% of value)?", spacing * 100.0, 2, 10, null);
   int ntrials = 100;
   gd.addNumericField("MC_#_Trials", ntrials, 0);
   gd.showDialog();
   if (gd.wasCanceled()) {
     return false;
   }
   int methodindex = gd.getNextChoiceIndex();
   conf = 0.01f * (float) gd.getNextNumber();
   int paramindex = gd.getNextChoiceIndex();
   spacing = 0.01 * gd.getNextNumber();
   ntrials = (int) gd.getNextNumber();
   if (methodindex == 0) {
     support_plane_errors_v2 erclass = new support_plane_errors_v2(this, 0.0001, 50, false, 0.1);
     int errindex = paramindex;
     int nfit = 0;
     for (int i = 0; i < labels.length; i++) {
       if (fixes[i] == 0) {
         nfit++;
       }
     }
     int npts = tempdata.length;
     int dofnum = npts - (nfit - 1) - 1;
     int dofden = npts - nfit - 1;
     double flim = (new jdist()).FLimit(dofnum, dofden, (double) conf);
     IJ.log("FLimit = " + (float) flim);
     if (flim == Double.NaN && flim < 1.0) {
       IJ.showMessage("Invalid Limiting F Value");
       return false;
     }
     double truespacing = Math.abs(params[errindex] * spacing);
     double[][] c2plot =
         erclass.geterrors(
             params, fixes, constraints, tempdata, weights, flim, truespacing, errindex);
     IJ.log("upper limit = " + c2plot[1][0] + " lower limit = " + c2plot[0][0]);
     IJ.log(
         "upper error = "
             + (c2plot[1][0] - params[errindex])
             + " lower error = "
             + (params[errindex] - c2plot[0][0]));
     int templength = c2plot[0].length;
     float[][] c2plotf = new float[2][templength - 1];
     for (int i = 0; i < (templength - 1); i++) {
       c2plotf[0][i] = (float) c2plot[0][i + 1];
       c2plotf[1][i] = (float) c2plot[1][i + 1];
     }
     new PlotWindow4("c2 plot", labels[errindex], "Chi^2", c2plotf[0], c2plotf[1]).draw();
   } else {
     StringBuffer sb = new StringBuffer();
     sb.append("Trial\t");
     for (int i = 0; i < labels.length; i++) {
       if (fixes[i] == 0) sb.append(labels[i] + "\t");
     }
     sb.append("chi^2");
     tw = new TextWindow("Monte Carlo Results", sb.toString(), "", 400, 400);
     redirect = true;
     monte_carlo_errors_v2 erclass = new monte_carlo_errors_v2(this, 0.0001, 50, false, 0.1);
     double[][] errors = erclass.geterrors(params, fixes, constraints, tempdata, weights, ntrials);
     sb = new StringBuffer();
     sb.append("StDev\t");
     for (int i = 0; i < errors.length; i++) {
       float[] ferr = new float[errors[0].length];
       for (int j = 0; j < ferr.length; j++) ferr[j] = (float) errors[i][j];
       float stdev = jstatistics.getstatistic("StDev", ferr, null);
       sb.append("" + stdev);
       if (i < (errors.length - 1)) sb.append("\t");
     }
     tw.append(sb.toString());
     redirect = false;
   }
   return true;
 }
Exemple #6
0
 private String fixLinuxString(String s) {
   StringBuffer sb = new StringBuffer(200);
   for (int i = 0; i < s.length(); i += 2) sb.append(s.charAt(i));
   return new String(sb);
 }