List of usage examples for java.util.stream DoubleStream of
public static DoubleStream of(double... values)
From source file:com.jscriptive.moneyfx.ui.chart.ChartFrame.java
private String getAccountLabel(Account account) { String accountLabel;/*from w ww . j a v a 2 s.co m*/ if (account == ALL_ACCOUNTS) { double balance = accountCombo.getItems().stream() .flatMapToDouble(a -> DoubleStream.of(a == ALL_ACCOUNTS ? 0.0 : a.getBalance().doubleValue())) .sum(); accountLabel = format(" All accounts [%s]", CurrencyFormat.getInstance().format(balance)); } else { accountLabel = format(" %s [%s]", account.toPresentableString(), account.getFormattedBalance()); } return accountLabel; }
From source file:com.jscriptive.moneyfx.ui.chart.ChartFrame.java
private double getSum(List<Transaction> transactions) { return abs(transactions.parallelStream() .flatMapToDouble(trx -> DoubleStream.of(trx.getAmount().doubleValue())).sum()); }
From source file:gr.iti.mklab.reveal.forensics.util.Util.java
/** * Calculate histogram/*from ww w . j a v a 2 s. co m*/ */ public static int[] createhistogram(double[] zmat, int bins) throws IOException { OptionalDouble max = DoubleStream.of(zmat).max(); OptionalDouble min = DoubleStream.of(zmat).min(); int[] result = new int[bins]; double binSize = (max.getAsDouble() - min.getAsDouble()) / bins; for (double d : zmat) { int bin = (int) ((d - min.getAsDouble()) / binSize); if (bin < 0) { /* this data is smaller than min */ System.out.println("this data point is smaller than min " + d); } else if (bin >= bins) { /* this data point is bigger than max */ result[bin - 1] += 1; } else { result[bin] += 1; } } return result; }
From source file:org.openbase.bco.ontology.lib.manager.aggregation.DataAggregation.java
private double calcTimeWeighting(final double[] timeWeightingArray, final int periodLength) { return DoubleStream.of(timeWeightingArray).sum() / periodLength; }