Example usage for java.util DoubleSummaryStatistics getMax

List of usage examples for java.util DoubleSummaryStatistics getMax

Introduction

In this page you can find the example usage for java.util DoubleSummaryStatistics getMax.

Prototype

public final double getMax() 

Source Link

Document

Returns the maximum recorded value, Double.NaN if any recorded value was NaN or Double.NEGATIVE_INFINITY if no values were recorded.

Usage

From source file:Main.java

public static void main(String[] args) {
    DoubleSummaryStatistics stats = new DoubleSummaryStatistics();
    stats.accept(100.0);//from   w  w  w. j  a va2s.co  m
    stats.accept(300.0);
    stats.accept(230.0);
    stats.accept(532.0);
    stats.accept(422.0);

    long count = stats.getCount();
    double sum = stats.getSum();
    double min = stats.getMin();
    double avg = stats.getAverage();
    double max = stats.getMax();

    System.out.printf("count=%d, sum=%.2f,  min=%.2f,  average=%.2f, max=%.2f%n", count, sum, min, max, avg);
}

From source file:io.yields.math.concepts.operator.Smoothness.java

public static List<Tuple> normalize(Collection<Tuple> tuples) {
    DoubleSummaryStatistics statsForX = tuples.stream()
            .collect(Collectors.summarizingDouble(tuple -> tuple.getX()));
    DoubleSummaryStatistics statsForY = tuples.stream()
            .collect(Collectors.summarizingDouble(tuple -> tuple.getY()));
    double minX = statsForX.getMin();
    double maxX = statsForX.getMax();
    double minY = statsForY.getMin();
    double maxY = statsForY.getMax();
    return tuples.stream().map(tuple -> {
        double x = (tuple.getX() - minX) / (maxX - minX);
        double y = (tuple.getY() - minY) / (maxY - minY);
        return new Tuple(x, y);
    }).collect(Collectors.toList());
}

From source file:io.yields.math.framework.kpi.StatDefinition.java

public StatDefinition(StatDefinition parent, String name, String description, DoubleSummaryStatistics stats,
        double referenceLevel) {
    this(parent, name, description, stats.getMin(), stats.getMax(), referenceLevel);
}

From source file:demir.terrier.matching.daat.FeaturedCandidateResult.java

private double[] GetMaxMin(double[] array) {
    DoubleSummaryStatistics stat = Arrays.stream(array).summaryStatistics();
    double[] MinMax = new double[2];
    MinMax[0] = stat.getMin();/*from  w  w  w . j  a v  a2s.c  om*/
    MinMax[1] = stat.getMax();

    return MinMax;
    /* ---------2----------------------------
     List b = Arrays.asList(ArrayUtils.toObject(array));
     System.out.println(Collections.min(b));
     System.out.println(Collections.max(b));
     */
}

From source file:com.epam.ta.reportportal.core.project.impl.ProjectInfoWidgetDataConverter.java

/**
 * <b>Test-cases statistics in unique launches</b> project info widget
 * content data-source/*from w w w. j  a  va2  s . co m*/
 * 
 * @param initial
 * @return
 */
public Map<String, List<ChartObject>> getTestCasesStatisticsProjectInfo(List<Launch> initial) {
    DecimalFormat formatter = new DecimalFormat("#####.##");
    final String MIN = "min";
    final String MAX = "max";
    final String AVG = "avg";
    String globalAverageSeria = "Median value in all unique launches";

    if (initial.isEmpty()) {
        return new HashMap<>();
    }

    Map<String, List<ChartObject>> result = new HashMap<>();
    Map<String, List<Launch>> grouped = groupBy(initial, BY_NAME);
    for (Entry<String, List<Launch>> pair : grouped.entrySet()) {
        ChartObject singleStat = new ChartObject();
        singleStat.setName(pair.getKey());
        Map<String, String> values = new HashMap<>();
        List<Launch> group = pair.getValue();

        DoubleSummaryStatistics statistics = group.stream()
                .mapToDouble(it -> it.getStatistics().getExecutionCounter().getTotal()).summaryStatistics();
        values.put(MIN, String.valueOf(statistics.getMin()));
        values.put(MAX, String.valueOf(statistics.getMax()));
        values.put(AVG, formatter.format(statistics.getAverage()));
        singleStat.setValues(values);

        result.put(pair.getKey(), Collections.singletonList(singleStat));
    }

    /*
     * Separate label for 'Median value in all unique launches' on the table
     */
    // TODO Implement new MEDIAN calculation!
    result.put(globalAverageSeria, Collections.singletonList(new ChartObject()));
    return result;
}

From source file:org.apache.metron.indexing.dao.metaalert.MetaScores.java

public MetaScores(List<Double> scores) {
    // A meta alert could be entirely alerts with no values.
    DoubleSummaryStatistics stats = scores.stream().mapToDouble(a -> a).summaryStatistics();
    metaScores.put("max", stats.getMax());
    metaScores.put("min", stats.getMin());
    metaScores.put("average", stats.getAverage());
    metaScores.put("count", stats.getCount());
    metaScores.put("sum", stats.getSum());

    // median isn't in the stats summary
    double[] arr = scores.stream().mapToDouble(d -> d).toArray();
    metaScores.put("median", new Median().evaluate(arr));
}

From source file:org.opennms.web.controller.trend.TrendController.java

private Map<String, String> variableReplacements(final List<Double> values) {
    final Map<String, String> replacements = new HashMap<>();

    final DoubleSummaryStatistics doubleSummaryStatistics = values.stream().mapToDouble(Double::doubleValue)
            .summaryStatistics();//from   w w w  .  j  a  v  a2s .  c o m

    replacements.put("${doubleMax}", String.format("%.2f", doubleSummaryStatistics.getMax()));
    replacements.put("${intMax}", String.format("%d", (int) doubleSummaryStatistics.getMax()));

    replacements.put("${doubleMin}", String.format("%.2f", doubleSummaryStatistics.getMin()));
    replacements.put("${intMin}", String.format("%d", (int) doubleSummaryStatistics.getMin()));

    replacements.put("${doubleAvg}", String.format("%.2f", doubleSummaryStatistics.getAverage()));
    replacements.put("${intAvg}", String.format("%d", (int) doubleSummaryStatistics.getAverage()));

    replacements.put("${doubleSum}", String.format("%.2f", doubleSummaryStatistics.getSum()));
    replacements.put("${intSum}", String.format("%d", (int) doubleSummaryStatistics.getSum()));

    for (int i = 0; i < values.size(); i++) {
        double current = values.get(i);

        replacements.put("${doubleValue[" + i + "]}", String.format("%.2f", current));
        replacements.put("${intValue[" + i + "]}", String.format("%d", (int) current));

        if (i > 0) {
            double previous = values.get(i - 1);
            double change = current - previous;

            replacements.put("${doubleValueChange[" + i + "]}", String.format("%+.2f", change));
            replacements.put("${intValueChange[" + i + "]}", String.format("%+d", (int) change));
        } else {
            replacements.put("${doubleValueChange[" + i + "]}", "NaN");
            replacements.put("${intValueChange[" + i + "]}", "NaN");
        }
    }

    if (values.size() > 0) {
        replacements.put("${doubleLastValueChange}",
                replacements.get("${doubleValueChange[" + (values.size() - 1) + "]}"));
        replacements.put("${intLastValueChange}",
                replacements.get("${intValueChange[" + (values.size() - 1) + "]}"));

        replacements.put("${doubleLastValue}", replacements.get("${doubleValue[" + (values.size() - 1) + "]}"));
        replacements.put("${intLastValue}", replacements.get("${intValue[" + (values.size() - 1) + "]}"));
    } else {
        replacements.put("${doubleLastValueChange}", "NaN");
        replacements.put("${intLastValueChange}", "NaN");

        replacements.put("${doubleLastValue}", "NaN");
        replacements.put("${intLastValue}", "NaN");
    }

    return replacements;
}