Example usage for org.apache.commons.math3.stat.descriptive SummaryStatistics getMin

List of usage examples for org.apache.commons.math3.stat.descriptive SummaryStatistics getMin

Introduction

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

Prototype

public double getMin() 

Source Link

Document

Returns the minimum of the values that have been added.

Usage

From source file:com.sop4j.SimpleStatistics.java

public static void main(String[] args) {
    final MersenneTwister rng = new MersenneTwister(); // used for RNG... READ THE DOCS!!!
    final int[] values = new int[NUM_VALUES];

    final DescriptiveStatistics descriptiveStats = new DescriptiveStatistics(); // stores values
    final SummaryStatistics summaryStats = new SummaryStatistics(); // doesn't store values
    final Frequency frequency = new Frequency();

    // add numbers into our stats
    for (int i = 0; i < NUM_VALUES; ++i) {
        values[i] = rng.nextInt(MAX_VALUE);

        descriptiveStats.addValue(values[i]);
        summaryStats.addValue(values[i]);
        frequency.addValue(values[i]);//  www . ja v a  2  s.  c o m
    }

    // print out some standard stats
    System.out.println("MIN: " + summaryStats.getMin());
    System.out.println("AVG: " + String.format("%.3f", summaryStats.getMean()));
    System.out.println("MAX: " + summaryStats.getMax());

    // get some more complex stats only offered by DescriptiveStatistics
    System.out.println("90%: " + descriptiveStats.getPercentile(90));
    System.out.println("MEDIAN: " + descriptiveStats.getPercentile(50));
    System.out.println("SKEWNESS: " + String.format("%.4f", descriptiveStats.getSkewness()));
    System.out.println("KURTOSIS: " + String.format("%.4f", descriptiveStats.getKurtosis()));

    // quick and dirty stats (need a little help from Guava to convert from int[] to double[])
    System.out.println("MIN: " + StatUtils.min(Doubles.toArray(Ints.asList(values))));
    System.out.println("AVG: " + String.format("%.4f", StatUtils.mean(Doubles.toArray(Ints.asList(values)))));
    System.out.println("MAX: " + StatUtils.max(Doubles.toArray(Ints.asList(values))));

    // some stats based upon frequencies
    System.out.println("NUM OF 7s: " + frequency.getCount(7));
    System.out.println("CUMULATIVE FREQUENCY OF 7: " + frequency.getCumFreq(7));
    System.out.println("PERCENTAGE OF 7s: " + frequency.getPct(7));
}

From source file:ijfx.plugins.display.AutoContrast.java

private static void setMinMax(ImageDisplay imageDisplay, Dataset dataset, SummaryStatistics stats,
        int channel) {

    double[] minMax;

    if (dataset != null) {
        dataset.setChannelMinimum(channel, stats.getMin());
        dataset.setChannelMaximum(channel, stats.getMax());
        dataset.update();/*from  w w  w .  j a va 2 s . com*/
    }

    if (imageDisplay != null) {
        DatasetView view = (DatasetView) imageDisplay.getActiveView();
        view.setChannelRange(channel, stats.getMin(), stats.getMax());

        view.update();
        view.getProjector().map();
    }
}

From source file:co.turnus.common.util.CommonDataUtil.java

public static StatisticalData createFrom(SummaryStatistics summary) {
    StatisticalData data = CommonFactory.eINSTANCE.createStatisticalData();
    if (summary.getN() != 0) {
        data.setMax(summary.getMax());/*from   w w w .  j  a va 2 s .  com*/
        data.setMin(summary.getMin());
        data.setSamples(summary.getN());
        data.setSum(summary.getSum());
        data.setVariance(summary.getVariance());
        data.setMean(summary.getMean());
    }
    return data;
}

From source file:net.sourceforge.jabm.report.AbstractReportVariables.java

public void recordSummaryStatistics(Object statName, Map<Object, Number> variables, SummaryStatistics stats) {
    variables.put(createVariable(statName + ".mean"), stats.getMean());
    variables.put(createVariable(statName + ".min"), stats.getMin());
    variables.put(createVariable(statName + ".max"), stats.getMax());
    variables.put(createVariable(statName + ".n"), stats.getN());
    variables.put(createVariable(statName + ".stdev"), stats.getStandardDeviation());
}

From source file:ijfx.ui.explorer.DefaultFolderManagerService.java

private Integer fetchMoreStatistics(ProgressHandler progress, List<Explorable> explorableList) {
    if (progress == null)
        progress = new SilentProgressHandler();
    progress.setStatus("Completing statistics of the objects");
    Integer elementAnalyzedCount = 0;
    int elements = explorableList.size();
    int i = 0;//from  www.j av  a2s  .  c o m
    for (Explorable e : explorableList) {
        if (!e.getMetaDataSet().containsKey(MetaData.STATS_PIXEL_MIN)) {
            progress.setProgress(i, elements);
            if (e instanceof ImageRecordIconizer) {
                ImageRecordIconizer iconizer = (ImageRecordIconizer) e;
                SummaryStatistics stats = statsService.getStatistics(iconizer.getImageRecord().getFile());
                iconizer.getMetaDataSet().putGeneric(MetaData.STATS_PIXEL_MIN, stats.getMin());
                iconizer.getMetaDataSet().putGeneric(MetaData.STATS_PIXEL_MAX, stats.getMax());
                iconizer.getMetaDataSet().putGeneric(MetaData.STATS_PIXEL_MEAN, stats.getMean());
                iconizer.getMetaDataSet().putGeneric(MetaData.STATS_PIXEL_STD_DEV, stats.getMean());
                elementAnalyzedCount++;
            }
        }
        i++;
    }
    return elementAnalyzedCount;
}

From source file:gr.cti.android.experimentation.controller.api.HistoryController.java

/**
 * Parse a time instant and create a TempReading object.
 *
 * @param millis     the millis of the timestamp.
 * @param function   the function to aggregate.
 * @param statistics the data values//from   w w  w  . j a v  a2  s . co  m
 * @return the aggregated TempReading for this time instant.
 */
private TempReading parse(final long millis, final String function, SummaryStatistics statistics) {
    final Double value;
    switch (function) {
    case "avg":
        value = statistics.getMean();
        break;
    case "max":
        value = statistics.getMax();
        break;
    case "min":
        value = statistics.getMin();
        break;
    case "var":
        value = statistics.getVariance();
        break;
    case "sum":
        value = statistics.getSum();
        break;
    default:
        value = statistics.getMean();
    }
    return new TempReading(millis, value);
}

From source file:fr.gael.drb.cortex.topic.sentinel3.jai.operator.QuicklookSlstrRIF.java

private BufferedImage toGrayScale(Raster in, PixelCorrection c, boolean invertColors, boolean ignoreBadStats) {
    int width = in.getWidth();
    int height = in.getHeight();
    // compute stats
    SummaryStatistics stats = new SummaryStatistics();
    for (int j = 0; j < height; j++) {
        for (int i = 0; i < width; i++) {
            int pixel = checkAndApplyCorrection(in.getSample(i, j, 0), c);
            if (pixel != c.nodata)
                stats.addValue(pixel);//from ww w . j  av  a 2 s  .co  m
        }
    }
    double lowerBound = Math.max(stats.getMin(), stats.getMean() - 3 * stats.getStandardDeviation());
    double upperBound = Math.min(stats.getMax(), stats.getMean() + 3 * stats.getStandardDeviation());

    if (!ignoreBadStats)
        if (Double.isNaN(stats.getMean()) || Double.isNaN(stats.getStandardDeviation())
                || stats.getStandardDeviation() < 1)
            throw new IllegalStateException("Ugly band stats. Acquired during night?");

    return toGrayScale(in, c, invertColors, lowerBound, upperBound);
}

From source file:ijfx.ui.plugin.panel.OverlayPanel.java

protected XYChart.Series<Double, Double> getOverlayHistogram(Overlay overlay) {

    Timer timer = timerService.getTimer(this.getClass());
    timer.start();/*from  w  w  w . jav  a2  s . com*/
    Double[] valueList = statsService.getValueList(currentDisplay(), overlay);
    timer.elapsed("Getting the stats");
    SummaryStatistics sumup = new SummaryStatistics();
    for (Double v : valueList) {
        sumup.addValue(v);
    }
    timer.elapsed("Building the sumup");

    double min = sumup.getMin();
    double max = sumup.getMax();
    double range = max - min;
    int bins = 100;//new Double(max - min).intValue();

    EmpiricalDistribution distribution = new EmpiricalDistribution(bins);

    double[] values = ArrayUtils.toPrimitive(valueList);
    Arrays.parallelSort(values);
    distribution.load(values);

    timer.elapsed("Sort and distrubution repartition up");

    XYChart.Series<Double, Double> serie = new XYChart.Series<>();
    ArrayList<Data<Double, Double>> data = new ArrayList<>(bins);
    double k = min;
    for (SummaryStatistics st : distribution.getBinStats()) {
        data.add(new Data<Double, Double>(k, new Double(st.getN())));
        k += range / bins;
    }

    serie.getData().clear();
    serie.getData().addAll(data);
    timer.elapsed("Creating charts");
    return serie;
}

From source file:net.adamjak.thomas.graph.application.gui.ResultsWidnow.java

private JTable createJtResults() {
    if (this.results.containsKey("resultsData")) {
        GraphTestResult[][] results = (GraphTestResult[][]) this.results.get("resultsData");

        String[] columnNames = { "Graph ID", "Avarage time", "Standard deviation", "Minimum", "Maximum" };
        Object[][] data = new Object[results[0].length][5];

        for (int graph = 0; graph < results[0].length; graph++) {
            SummaryStatistics summaryStatistics = new SummaryStatistics();

            for (int run = 0; run < results.length; run++) {
                summaryStatistics.addValue((double) results[run][graph].getValue("timeInSeconds"));
            }/*from w ww  .  j  a v  a  2s. co m*/

            data[graph][0] = graph;
            data[graph][1] = summaryStatistics.getMean();
            data[graph][2] = summaryStatistics.getStandardDeviation();
            data[graph][3] = summaryStatistics.getMin();
            data[graph][4] = summaryStatistics.getMax();
        }

        return new JTable(data, columnNames);
    } else {
        String[] columnNames = { "Description", "Result" };
        Object[][] data = new Object[this.results.keySet().size()][2];

        int i = 0;
        for (String key : this.results.keySet()) {
            data[i][0] = key;
            data[i][1] = this.results.get(key);
            i++;
        }

        return new JTable(data, columnNames);
    }
}

From source file:de.thkwalter.koordinatensystem.Achsendimensionierung.java

/**
 * Diese Methode bestimmt die Wertebereiche in x- und y-Richtung.
 * //from  w  ww  .  java2  s. co  m
 * @param punkte Die Punktemenge.
 * 
 * @return Der Wertebereich der Punktemenge.
 */
private Wertebereich wertebereichBestimmen(Vector2D[] punkte) {
    // Die Objekte, die zur Bestimmung der minimalen und maximalen Werte verwendet werden, werden erzeugt.
    SummaryStatistics summaryStatisticsX = new SummaryStatistics();
    SummaryStatistics summaryStatisticsY = new SummaryStatistics();

    // Die Objekte, die zur Bestimmung der minimalen und maximalen Werte verwendet werden, werden initialisiert.
    for (Vector2D punkt : punkte) {
        summaryStatisticsX.addValue(punkt.getX());
        summaryStatisticsY.addValue(punkt.getY());
    }

    // Die Maxima und Minima werden bestimmt.
    double maxX = summaryStatisticsX.getMax();
    double maxY = summaryStatisticsY.getMax();
    double minX = summaryStatisticsX.getMin();
    double minY = summaryStatisticsY.getMin();

    // Der maximale Wertebereich der Punktemenge wird zurckgegeben.
    return new Wertebereich(maxX, maxY, minX, minY);
}