Example usage for org.apache.commons.math.stat.descriptive DescriptiveStatistics getMin

List of usage examples for org.apache.commons.math.stat.descriptive DescriptiveStatistics getMin

Introduction

In this page you can find the example usage for org.apache.commons.math.stat.descriptive DescriptiveStatistics getMin.

Prototype

public double getMin() 

Source Link

Document

Returns the minimum of the available values

Usage

From source file:org.matsim.contrib.socnetgen.sna.graph.io.PajekDegreeColorizer.java

public PajekDegreeColorizer(Graph g, boolean logScale) {
    super();//from  w  w w. ja  va 2 s  .c  o m
    setLogScale(logScale);
    DescriptiveStatistics stats = Degree.getInstance().statistics(g.getVertices());
    k_min = stats.getMin();
    k_max = stats.getMax();
}

From source file:org.matsim.contrib.socnetgen.sna.graph.spatial.io.VertexDegreeColorizer.java

/**
 * Creates a colorizer which color spectrum is scaled to the degree
 * distribution of <tt>graph</tt>.
 * //from  w  w w  . j  a  v  a2 s  . c  om
 * @param graph
 *            a graph
 */
public VertexDegreeColorizer(Graph graph) {
    Degree degree = Degree.getInstance();
    DescriptiveStatistics distr = degree.statistics(graph.getVertices());
    k_min = (int) distr.getMin();
    k_max = (int) distr.getMax();
}

From source file:org.openehealth.ipf.commons.test.performance.processingtime.ProcessingTimeDescriptiveStatistics.java

/**
 * Returns statistical summary of all the data.
 * //ww  w  . java 2  s.c o  m
 * @return a <code>StatisticalSummary</code> object
 */
@Override
public StatisticalSummary getStatisticalSummaryByName(String name) {
    DescriptiveStatistics stats = statisticsByMeasurementName.get(name);

    return new StatisticalSummaryValues(stats.getMean(), stats.getVariance(), stats.getN(), stats.getMax(),
            stats.getMin(), stats.getSum());
}

From source file:org.processmining.analysis.performance.dottedchart.ui.MetricsPanel.java

/**
 * Displays the performance metrics of each pattern on the east side of the
 * plug-in window./* www.ja v  a 2  s.  c  o m*/
 * 
 * @param sortedArray
 *            int[]
 */

public void displayPerformanceMetrics() {
    String type = dcPanel.getTimeOption();
    ArrayList<DescriptiveStatistics> aList = dcModel.getTimeStatistics();
    ArrayList<String> aTitles = dcModel.getDescriptiveStatisticsTitles();

    ArrayList<String> sortedTitleList = dcModel.getSortedKeySetList();

    this.removeAll();
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    // add time option menu
    this.add(Box.createRigidArea(new Dimension(5, 10)));
    JPanel menuPanel = new JPanel(new BorderLayout());
    menuPanel.setPreferredSize(new Dimension(160, 45));
    menuPanel.setMaximumSize(new Dimension(180, 45));
    timeSortLabel.setAlignmentX(LEFT_ALIGNMENT);
    menuPanel.add(timeSortLabel, BorderLayout.NORTH);
    timeBox.setMaximumSize(new Dimension(160, 20));
    timeBox.setAlignmentX(LEFT_ALIGNMENT);
    menuPanel.add(Box.createRigidArea(new Dimension(5, 0)));
    menuPanel.add(timeBox, BorderLayout.CENTER);
    this.add(menuPanel);
    this.add(Box.createRigidArea(new Dimension(5, 10)));

    // for each frequency get the set of patterns that have that frequency
    // (run from high frequency to low)
    int size = 0;
    for (int i = 0; i < aList.size(); i++) {
        try {
            String key;
            DescriptiveStatistics currentDS = null;
            if (i != 0)
                key = sortedTitleList.get(i - 1);
            else {
                key = aTitles.get(0);
                currentDS = aList.get(i);
            }

            if (i > 0 && dcModel.getTypeHashMap().equals(DottedChartPanel.ST_INST)
                    && !dcModel.getInstanceTypeToKeep().contains(key))
                continue;
            size++;

            if (i > 0) {
                for (int j = 1; j < aTitles.size(); j++) {
                    if (aTitles.get(j).equals(key))
                        currentDS = aList.get(j);
                }
            }
            AbstractTableModel otm;
            // create labels that contains information about the pattern
            if (i == 0)
                otm = new OverallMetricTableModel();
            else
                otm = new OneMetricTableModel();
            DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
            dtcr.setBackground(new Color(235, 235, 235));
            JTable table = new JTable(otm);
            table.setPreferredSize(new Dimension(200, 55));
            table.setMaximumSize(new Dimension(200, 55));
            table.getColumnModel().getColumn(0).setPreferredWidth(70);
            table.getColumnModel().getColumn(0).setMaxWidth(100);
            table.getTableHeader().setFont(new Font("SansSerif", Font.PLAIN, 12));
            table.getColumnModel().getColumn(0).setCellRenderer(dtcr);
            table.setBorder(BorderFactory.createEtchedBorder());

            // place throughput times in table
            if (type.equals(DottedChartPanel.TIME_ACTUAL)) {
                if (i == 0) {
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryLeft()), 0, 1);
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryRight()), 1, 1);
                } else {
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getStartDateofLogUniList(key)), 0,
                            1);
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getEndDateofLogUniList(key)), 1,
                            1);
                }
                table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1);
            } else if (type.equals(DottedChartPanel.TIME_RELATIVE_TIME)) {
                if (i == 0) {
                    table.setValueAt(formatDate(dcModel.getLogBoundaryLeft()), 0, 1);
                    table.setValueAt(formatDate(dcModel.getLogBoundaryRight()), 1, 1);
                } else {
                    table.setValueAt(formatDate(dcModel.getStartDateofLogUniList(key)), 0, 1);
                    table.setValueAt(formatDate(dcModel.getEndDateofLogUniList(key)), 1, 1);
                }
                table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1);
            } else if (type.equals(DottedChartPanel.TIME_RELATIVE_RATIO)) {
                if (i == 0) {
                    table.setValueAt(formatRatio(dcModel.getLogBoundaryLeft()), 0, 1);
                    table.setValueAt(formatRatio(dcModel.getLogBoundaryRight()), 1, 1);
                } else {
                    table.setValueAt(formatRatio(dcModel.getStartDateofLogUniList(key)), 0, 1);
                    table.setValueAt(formatRatio(dcModel.getEndDateofLogUniList(key)), 1, 1);
                }
                table.setValueAt(formatString(currentDS.getMean() / 100, 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin() / 100, 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax() / 100, 5), 4, 1);
            } else if (type.equals(DottedChartPanel.TIME_LOGICAL)
                    || type.equals(DottedChartPanel.TIME_LOGICAL_RELATIVE)) {
                if (i == 0) {
                    table.setValueAt(formatString(dcModel.getLogBoundaryLeft().getTime(), 5), 0, 1);
                    table.setValueAt(formatString(dcModel.getLogBoundaryRight().getTime(), 5), 1, 1);
                } else {
                    table.setValueAt(formatString((dcModel.getStartDateofLogUniList(key)).getTime(), 5), 0, 1);
                    table.setValueAt(formatString((dcModel.getEndDateofLogUniList(key)).getTime(), 5), 1, 1);
                }
                table.setValueAt(formatString(currentDS.getMean(), 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin(), 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax(), 5), 4, 1);
            }

            JPanel tempPanel = new JPanel(new BorderLayout());
            table.setAlignmentX(CENTER_ALIGNMENT);
            tempPanel.setPreferredSize(new Dimension(160, 98));
            tempPanel.setMaximumSize(new Dimension(180, 98));
            tempPanel.add(table.getTableHeader(), BorderLayout.NORTH);
            tempPanel.add(table, BorderLayout.CENTER);
            JPanel tempPanel2 = new JPanel(new BorderLayout());
            JLabel patternLabel = new JLabel("Component " + key + ":");
            patternLabel.setAlignmentX(LEFT_ALIGNMENT);

            JLabel frequencyLabel = null;
            if (i == 0)
                frequencyLabel = new JLabel("# of components: " + currentDS.getN());
            else
                frequencyLabel = new JLabel("# of dots: " + dcModel.getNumberOfLogUnits(key));

            frequencyLabel.setAlignmentX(LEFT_ALIGNMENT);
            frequencyLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
            tempPanel2.add(patternLabel, BorderLayout.NORTH);
            tempPanel2.add(frequencyLabel, BorderLayout.CENTER);
            tempPanel2.add(tempPanel, BorderLayout.SOUTH);
            this.add(tempPanel2);
            this.add(Box.createRigidArea(new Dimension(5, 10)));
        } catch (NullPointerException ex) {
            // can occur when patternMap does not contain a pattern with
            // this frequency
            size--;
        }
    }
    // make sure the pattern performance information is displayed properly
    this.setPreferredSize(new Dimension(200, 140 * (size + 1)));
    this.revalidate();
    this.repaint();

}

From source file:org.processmining.analysis.performance.fsmanalysis.FSMPerformanceAnalysisUI.java

protected double getData(DescriptiveStatistics ds) {
    String sort = (String) measureSort.getValue();
    if (sort.equals("Minimum")) {
        return ds.getMin();
    } else if (sort.equals("Average")) {
        return (ds.getMean());
    } else if (sort.equals("Median")) {
        return (ds.getPercentile(50));
    } else if (sort.equals("Maximum")) {
        return (ds.getMax());
    } else if (sort.equals("Sum")) {
        return (ds.getSum());
    } else if (sort.equals("StandDev")) {
        return (ds.getStandardDeviation());
    } else if (sort.equals("Variance")) {
        return (ds.getStandardDeviation() * ds.getStandardDeviation());
    } else if (sort.equals("Frequency")) {
        return (ds.getN());
    }/*from w ww  . j  av a 2  s.c om*/
    return 0.0;
}

From source file:org.prom5.analysis.performance.dottedchart.ui.MetricsPanel.java

/**
 * Displays the performance metrics of each pattern on the east side of the
 * plug-in window./*w w w .  j  a  v a2  s .  c  o  m*/
 * @param sortedArray int[]
 */

public void displayPerformanceMetrics() {
    String type = dcPanel.getTimeOption();
    ArrayList<DescriptiveStatistics> aList = dcModel.getTimeStatistics();
    ArrayList<String> aTitles = dcModel.getDescriptiveStatisticsTitles();

    ArrayList<String> sortedTitleList = dcModel.getSortedKeySetList();

    this.removeAll();
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    //add time option menu
    this.add(Box.createRigidArea(new Dimension(5, 10)));
    JPanel menuPanel = new JPanel(new BorderLayout());
    menuPanel.setPreferredSize(new Dimension(160, 45));
    menuPanel.setMaximumSize(new Dimension(180, 45));
    timeSortLabel.setAlignmentX(LEFT_ALIGNMENT);
    menuPanel.add(timeSortLabel, BorderLayout.NORTH);
    timeBox.setMaximumSize(new Dimension(160, 20));
    timeBox.setAlignmentX(LEFT_ALIGNMENT);
    menuPanel.add(Box.createRigidArea(new Dimension(5, 0)));
    menuPanel.add(timeBox, BorderLayout.CENTER);
    this.add(menuPanel);
    this.add(Box.createRigidArea(new Dimension(5, 10)));

    //for each frequency get the set of patterns that have that frequency
    //(run from high frequency to low)
    int size = 0;
    for (int i = 0; i < aList.size(); i++) {
        try {
            String key;
            DescriptiveStatistics currentDS = null;
            if (i != 0)
                key = sortedTitleList.get(i - 1);
            else {
                key = aTitles.get(0);
                currentDS = aList.get(i);
            }

            if (i > 0 && dcModel.getTypeHashMap().equals(DottedChartPanel.ST_INST)
                    && !dcModel.getInstanceTypeToKeep().contains(key))
                continue;
            size++;

            if (i > 0) {
                for (int j = 1; j < aTitles.size(); j++) {
                    if (aTitles.get(j).equals(key))
                        currentDS = aList.get(j);
                }
            }
            AbstractTableModel otm;
            //create labels that contains information about the pattern
            if (i == 0)
                otm = new OverallMetricTableModel();
            else
                otm = new OneMetricTableModel();
            DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
            dtcr.setBackground(new Color(235, 235, 235));
            JTable table = new JTable(otm);
            table.setPreferredSize(new Dimension(200, 55));
            table.setMaximumSize(new Dimension(200, 55));
            table.getColumnModel().getColumn(0).setPreferredWidth(70);
            table.getColumnModel().getColumn(0).setMaxWidth(100);
            table.getTableHeader().setFont(new Font("SansSerif", Font.PLAIN, 12));
            table.getColumnModel().getColumn(0).setCellRenderer(dtcr);
            table.setBorder(BorderFactory.createEtchedBorder());

            //place throughput times in table
            if (type.equals(DottedChartPanel.TIME_ACTUAL)) {
                if (i == 0) {
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryLeft()), 0, 1);
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getLogBoundaryRight()), 1, 1);
                } else {
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getStartDateofLogUniList(key)), 0,
                            1);
                    table.setValueAt(DateFormat.getInstance().format(dcModel.getEndDateofLogUniList(key)), 1,
                            1);
                }
                table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1);
            } else if (type.equals(DottedChartPanel.TIME_RELATIVE_TIME)) {
                if (i == 0) {
                    table.setValueAt(formatDate(dcModel.getLogBoundaryLeft()), 0, 1);
                    table.setValueAt(formatDate(dcModel.getLogBoundaryRight()), 1, 1);
                } else {
                    table.setValueAt(formatDate(dcModel.getStartDateofLogUniList(key)), 0, 1);
                    table.setValueAt(formatDate(dcModel.getEndDateofLogUniList(key)), 1, 1);
                }
                table.setValueAt(formatString(currentDS.getMean() / timeDivider, 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin() / timeDivider, 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax() / timeDivider, 5), 4, 1);
            } else if (type.equals(DottedChartPanel.TIME_RELATIVE_RATIO)) {
                if (i == 0) {
                    table.setValueAt(formatRatio(dcModel.getLogBoundaryLeft()), 0, 1);
                    table.setValueAt(formatRatio(dcModel.getLogBoundaryRight()), 1, 1);
                } else {
                    table.setValueAt(formatRatio(dcModel.getStartDateofLogUniList(key)), 0, 1);
                    table.setValueAt(formatRatio(dcModel.getEndDateofLogUniList(key)), 1, 1);
                }
                table.setValueAt(formatString(currentDS.getMean() / 100, 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin() / 100, 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax() / 100, 5), 4, 1);
            } else if (type.equals(DottedChartPanel.TIME_LOGICAL)
                    || type.equals(DottedChartPanel.TIME_LOGICAL_RELATIVE)) {
                if (i == 0) {
                    table.setValueAt(formatString(dcModel.getLogBoundaryLeft().getTime(), 5), 0, 1);
                    table.setValueAt(formatString(dcModel.getLogBoundaryRight().getTime(), 5), 1, 1);
                } else {
                    table.setValueAt(formatString((dcModel.getStartDateofLogUniList(key)).getTime(), 5), 0, 1);
                    table.setValueAt(formatString((dcModel.getEndDateofLogUniList(key)).getTime(), 5), 1, 1);
                }
                table.setValueAt(formatString(currentDS.getMean(), 5), 2, 1);
                table.setValueAt(formatString(currentDS.getMin(), 5), 3, 1);
                table.setValueAt(formatString(currentDS.getMax(), 5), 4, 1);
            }

            JPanel tempPanel = new JPanel(new BorderLayout());
            table.setAlignmentX(CENTER_ALIGNMENT);
            tempPanel.setPreferredSize(new Dimension(160, 98));
            tempPanel.setMaximumSize(new Dimension(180, 98));
            tempPanel.add(table.getTableHeader(), BorderLayout.NORTH);
            tempPanel.add(table, BorderLayout.CENTER);
            JPanel tempPanel2 = new JPanel(new BorderLayout());
            JLabel patternLabel = new JLabel("Component " + key + ":");
            patternLabel.setAlignmentX(LEFT_ALIGNMENT);

            JLabel frequencyLabel = null;
            if (i == 0)
                frequencyLabel = new JLabel("# of components: " + currentDS.getN());
            else
                frequencyLabel = new JLabel("# of dots: " + dcModel.getNumberOfLogUnits(key));

            frequencyLabel.setAlignmentX(LEFT_ALIGNMENT);
            frequencyLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
            tempPanel2.add(patternLabel, BorderLayout.NORTH);
            tempPanel2.add(frequencyLabel, BorderLayout.CENTER);
            tempPanel2.add(tempPanel, BorderLayout.SOUTH);
            this.add(tempPanel2);
            this.add(Box.createRigidArea(new Dimension(5, 10)));
        } catch (NullPointerException ex) {
            //can occur when patternMap does not contain a pattern with this frequency
            size--;
        }
    }
    //make sure the pattern performance information is displayed properly
    this.setPreferredSize(new Dimension(200, 140 * (size + 1)));
    this.revalidate();
    this.repaint();

}

From source file:org.tellervo.desktop.graph.SkeletonPlot.java

private Integer getSkeletonCategoryFromCropper1979(Integer value, DescriptiveStatistics windowStats,
        Double criticalLevel) {//from w w  w  .j  a  v  a  2 s .  c  o  m
    Integer skeletonCategory = 0;

    if (criticalLevel == null)
        criticalLevel = 0.5;
    double mean = windowStats.getMean();
    double stdev = windowStats.getStandardDeviation();
    double smallRingThreshold = mean - (stdev * criticalLevel);
    int min = (int) windowStats.getMin();

    if (value == min) {
        skeletonCategory = 10;
    } else if (value > smallRingThreshold) {
        skeletonCategory = 0;
    } else {
        Integer range = (int) (smallRingThreshold - min);
        Integer categoryStepSize = range / 10;
        skeletonCategory = (int) (0 - ((value - smallRingThreshold) / categoryStepSize));
    }

    return skeletonCategory;
}

From source file:org.tellervo.desktop.graph.SkeletonPlot.java

private Integer getSkeletonCategoryFromPercentiles(Integer value, DescriptiveStatistics windowStats) {
    Integer skeletonCategory = 0;
    // Calculate skeleton category
    if (value == (int) windowStats.getMin()) {
        skeletonCategory = 10;/*from w  ww .  j a  v  a2 s.c  om*/
    } else if (value < windowStats.getPercentile(10)) {
        skeletonCategory = 9;
    } else if (value < windowStats.getPercentile(15)) {
        skeletonCategory = 8;
    } else if (value < windowStats.getPercentile(20)) {
        skeletonCategory = 7;
    } else if (value < windowStats.getPercentile(25)) {
        skeletonCategory = 6;
    } else if (value < windowStats.getPercentile(30)) {
        skeletonCategory = 5;
    } else if (value < windowStats.getPercentile(35)) {
        skeletonCategory = 4;
    } else if (value < windowStats.getPercentile(40)) {
        skeletonCategory = 3;
    } else if (value < windowStats.getPercentile(45)) {
        skeletonCategory = 2;
    } else if (value < windowStats.getPercentile(50)) {
        skeletonCategory = 1;
    }

    return skeletonCategory;
}

From source file:playground.johannes.gsv.analysis.CountsCompareAnalyzer.java

@Override
public void notifyAfterMobsim(AfterMobsimEvent event) {
    Network network = event.getControler().getScenario().getNetwork();
    DescriptiveStatistics error = new DescriptiveStatistics();
    DescriptiveStatistics errorAbs = new DescriptiveStatistics();
    DescriptivePiStatistics errorWeighted = new WSMStatsFactory().newInstance();

    TDoubleArrayList errorVals = new TDoubleArrayList();
    TDoubleArrayList caps = new TDoubleArrayList();
    TDoubleArrayList speeds = new TDoubleArrayList();

    for (Count count : counts.getCounts().values()) {
        if (!count.getLocId().toString().startsWith(ODCalibrator.VIRTUAL_ID_PREFIX)) {
            double obsVal = 0;
            for (int i = 1; i < 25; i++) {
                obsVal += count.getVolume(i).getValue();
            }/*w w  w .  j a  va 2s  . c om*/

            if (obsVal > 0) {
                double simVal = calculator.getOccupancy(count.getLocId());
                simVal *= factor;

                double err = (simVal - obsVal) / obsVal;

                error.addValue(err);
                errorAbs.addValue(Math.abs(err));
                errorWeighted.addValue(Math.abs(err), 1 / obsVal);

                Link link = network.getLinks().get(count.getLocId());
                errorVals.add(Math.abs(err));
                caps.add(link.getCapacity());
                speeds.add(link.getFreespeed());
            }
        }
    }

    logger.info(String.format("Relative counts error: mean = %s, var = %s, stderr = %s, min = %s, max = %s",
            error.getMean(), error.getVariance(), error.getStandardDeviation(), error.getMin(),
            error.getMax()));
    logger.info(String.format(
            "Absolute relative counts error: mean = %s, var = %s, stderr = %s, min = %s, max = %s",
            errorAbs.getMean(), errorAbs.getVariance(), errorAbs.getStandardDeviation(), errorAbs.getMin(),
            errorAbs.getMax()));
    logger.info(String.format(
            "Absolute weigthed relative counts error: mean = %s, var = %s, stderr = %s, min = %s, max = %s",
            errorWeighted.getMean(), errorWeighted.getVariance(), errorWeighted.getStandardDeviation(),
            errorWeighted.getMin(), errorWeighted.getMax()));

    String outdir = event.getControler().getControlerIO().getIterationPath(event.getIteration());

    try {
        TDoubleDoubleHashMap map = Correlations.mean(caps.toNativeArray(), errorVals.toNativeArray());
        TXTWriter.writeMap(map, "capacity", "counts", String.format("%s/countsError.capacity.txt", outdir));

        map = Correlations.mean(speeds.toNativeArray(), errorVals.toNativeArray());
        TXTWriter.writeMap(map, "speed", "counts", String.format("%s/countsError.speed.txt", outdir));

        TXTWriter.writeMap(Histogram.createHistogram(error, new LinearDiscretizer(0.1), false), "Error",
                "Frequency", String.format("%s/countsError.hist.txt", outdir));
        TXTWriter.writeMap(Histogram.createHistogram(errorAbs, new LinearDiscretizer(0.1), false),
                "Error (absolute)", "Frequency", String.format("%s/countsErrorAbs.hist.txt", outdir));
        TXTWriter.writeMap(Histogram.createHistogram(errorWeighted, new LinearDiscretizer(0.1), true),
                "Error (weighted)", "Frequency", String.format("%s/countsErrorWeighted.hist.txt", outdir));

        CountsCompare2GeoJSON.write(calculator, counts, factor, network, outdir);
        NetworkLoad2GeoJSON.write(event.getControler().getScenario().getNetwork(), calculator, factor,
                outdir + "/network.json");
    } catch (IOException e) {
        e.printStackTrace();
    }

    String rootOutDir = event.getControler().getControlerIO().getOutputPath();
    boolean append = false;
    if (event.getIteration() > 0) {
        append = true;
    }
    writeErrorFile(error, String.format("%s/countsError.txt", rootOutDir), append);
    writeErrorFile(errorAbs, String.format("%s/countsAbsError.txt", rootOutDir), append);
}

From source file:playground.johannes.gsv.analysis.CountsCompareAnalyzer.java

private void writeErrorFile(DescriptiveStatistics error, String file, boolean append) {
    try {//from   www .  j  av  a2  s  .  co  m
        BufferedWriter writer = new BufferedWriter(new FileWriter(file, append));
        if (!append) {
            // write header
            writer.write("mean\tvar\tstderr\tmin\tmax");
            writer.newLine();
        }

        writer.write(String.valueOf(error.getMean()));
        writer.write("\t");
        writer.write(String.valueOf(error.getVariance()));
        writer.write("\t");
        writer.write(String.valueOf(error.getStandardDeviation()));
        writer.write("\t");
        writer.write(String.valueOf(error.getMin()));
        writer.write("\t");
        writer.write(String.valueOf(error.getMax()));
        writer.newLine();

        writer.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}