private double min(double... numbers) { return Arrays.stream(numbers).min().getAsDouble(); }
public static double min(double... values) { return DoubleStream.of(values) .min() .getAsDouble(); }
private double min(double... numbers) { return Arrays.stream(numbers).min().getAsDouble(); }
public static double min(double... nums) { if(nums.length == 0) return Double.MIN_VALUE; return Arrays.stream(nums).min().getAsDouble(); }
@Override public OptionalDouble execute() { try (final DoubleStream stream = buildPrevious()) { return stream.min(); } } }
private double minInterClusterDissimilarityForPoint( int otherClusterID, double[] point, Map<Integer, Iterable<double[]>> clusteredPointsMap) { return clusteredPointsMap.entrySet().stream().mapToDouble(entry -> { // only compute dissimilarities with other clusters if (entry.getKey().equals(otherClusterID)) { return Double.POSITIVE_INFINITY; } return clusterDissimilarityForPoint(point, iterableToList(entry.getValue()), false); }).min().orElse(Double.POSITIVE_INFINITY); }
default OptionalDouble min(DoublePipeline pipeline) { requireNonNull(pipeline); return optimize(pipeline).getAsDoubleStream().min(); }
double min = load == null ? 0 : targetsInScope.stream().mapToDouble((key) -> load.get(key)).min().getAsDouble(); for (int target : targetsInScope) { IndexAndWeights val = orig.get(target);
private SymbolStatsEstimate buildSymbolStatistics(List<Object> values, Session session, Type type) { List<Object> nonNullValues = values.stream() .filter(Objects::nonNull) .collect(toImmutableList()); if (nonNullValues.isEmpty()) { return SymbolStatsEstimate.zero(); } double[] valuesAsDoubles = nonNullValues.stream() .map(value -> toStatsRepresentation(metadata, session, type, value)) .filter(OptionalDouble::isPresent) .mapToDouble(OptionalDouble::getAsDouble) .toArray(); double lowValue = DoubleStream.of(valuesAsDoubles).min().orElse(Double.NEGATIVE_INFINITY); double highValue = DoubleStream.of(valuesAsDoubles).max().orElse(Double.POSITIVE_INFINITY); double valuesCount = values.size(); double nonNullValuesCount = nonNullValues.size(); long distinctValuesCount = nonNullValues.stream().distinct().count(); return SymbolStatsEstimate.builder() .setNullsFraction((valuesCount - nonNullValuesCount) / valuesCount) .setLowValue(lowValue) .setHighValue(highValue) .setDistinctValuesCount(distinctValuesCount) .build(); } }
public void testEquivalentStreams() { // For datasets of many double values created from an array, we test many combinations of finite // and non-finite values: for (ManyValues values : ALL_MANY_VALUES) { double[] array = values.asArray(); Stats stats = Stats.of(array); // instance methods on Stats vs on instance methods on DoubleStream assertThat(stats.count()).isEqualTo(stream(array).count()); assertEquivalent(stats.mean(), stream(array).average().getAsDouble()); assertEquivalent(stats.sum(), stream(array).sum()); assertEquivalent(stats.max(), stream(array).max().getAsDouble()); assertEquivalent(stats.min(), stream(array).min().getAsDouble()); // static method on Stats vs on instance method on DoubleStream assertEquivalent(Stats.meanOf(array), stream(array).average().getAsDouble()); // instance methods on Stats vs instance methods on DoubleSummaryStatistics DoubleSummaryStatistics streamStats = stream(array).summaryStatistics(); assertThat(stats.count()).isEqualTo(streamStats.getCount()); assertEquivalent(stats.mean(), streamStats.getAverage()); assertEquivalent(stats.sum(), streamStats.getSum()); assertEquivalent(stats.max(), streamStats.getMax()); assertEquivalent(stats.min(), streamStats.getMin()); } }
/** * Find the minimum value in a window of values * If all values are missing/null/NaN, the return value will be NaN */ public static double min(double[] values) { return Arrays.stream(values).min().orElse(Double.NaN); }
/** * Map all elements of a stream to a double and get the min. * * @param <T> Type of Stream which must match type of mapper * @param stream the value of stream * @param mapper the value of mapper * @return the double */ public static <T> double minStream(Stream<T> stream, ToDoubleFunction<T> mapper) { return stream.mapToDouble(mapper).min().orElse(Double.POSITIVE_INFINITY); }
public static double min(double... values) { return DoubleStream.of(values) .min() .getAsDouble(); }
/** * Min double. * * @param history the history * @return the double */ public double min(@Nonnull List<StepRecord> history) { return history.stream().mapToDouble(x -> x.fitness).min().orElse(Double.NaN); }
/** * Gets the min X. * * @return the min X */ private double getMinX() { return lines.values().stream().mapToDouble(l -> l.getPosition().getMinX()).min() .getAsDouble(); }
/** * Find the minimum value in a window of values * If all values are missing/null/NaN, the return value will be NaN */ public static double min(double[] values) { return Arrays.stream(values).min().orElse(Double.NaN); }
/** * Min double. * * @param history the history * @return the double */ public double min(@Nonnull List<StepRecord> history) { return history.stream().mapToDouble(x -> x.fitness).min().orElse(Double.NaN); }
public static double normalizedRMSE(double[] labels, double[] predictions){ double rmse =rmse(labels, predictions); double max = Arrays.stream(labels).max().getAsDouble(); double min = Arrays.stream(labels).min().getAsDouble(); return rmse/(max-min); } }
public double min() { // This is a lie if the winning centroid's weight > 1 return perThreadHistogramBins.values().stream().flatMap(List::stream).map(b -> b.dist.centroids()). mapToDouble(cs -> getFirst(cs, new Centroid(MAX_VALUE)).mean()).min().orElse(NaN); }
private void outputStats(String indexName, String statsName, Function<PerfResult, Long> statsProvider, Collection<PerfResult> results) { double min = results.stream().mapToDouble(r -> statsProvider.apply(r) / (double) r.count).min().orElse(-1) / NANOS_TO_MILLIS; double max = results.stream().mapToDouble(r -> statsProvider.apply(r) / (double) r.count).max().orElse(-1) / NANOS_TO_MILLIS; double avg = results.stream().mapToDouble(r -> statsProvider.apply(r) / (double) r.count).average().orElse(-1) / NANOS_TO_MILLIS; System.out.println(String.format("%s.%s: Min = %.2f us, Max = %.2f us, Avg = %.2f us", indexName, statsName, min, max, avg)); }