java.util.DoubleSummaryStatistics Java Examples

The following examples show how to use java.util.DoubleSummaryStatistics. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CLI.java    From SLP-Core with MIT License 6 votes vote down vote up
private static void predict() {
	File inDir = getTestFile();
	File counterFile = getCounterFile();
	if (inDir == null || !inDir.exists()) {
		exit("Test path does not exist: " + getArg(TEST));
	} else if (counterFile == null || !counterFile.exists()) {
		exit("Counter file to use not found: " + getArg(COUNTER));
	}
	
	Stream<Pair<File, List<List<Double>>>> fileMRRs = modelRunner.predictDirectory(inDir);
	int[] fileCount = { 0 };
	DoubleSummaryStatistics stats = modelRunner.getStats(
			fileMRRs.peek(f -> Writer.writeEntropies(lexerRunner, f))
			.peek(f -> fileCount[0]++));
	System.out.printf("Testing complete, modeled %d files with %d tokens yielding average MRR:\t%.4f\n",
			fileCount[0], stats.getCount(), stats.getAverage());
}
 
Example #2
Source File: CollectAndSummaryStatisticsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleStatistics() {
    List<DoubleSummaryStatistics> instances = new ArrayList<>();
    instances.add(countTo(1000).stream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).stream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).stream().mapToDouble(i -> i).collect(DoubleSummaryStatistics::new,
                                                                     DoubleSummaryStatistics::accept,
                                                                     DoubleSummaryStatistics::combine));
    instances.add(countTo(1000).parallelStream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).collect(DoubleSummaryStatistics::new,
                                                                             DoubleSummaryStatistics::accept,
                                                                             DoubleSummaryStatistics::combine));

    for (DoubleSummaryStatistics stats : instances) {
        assertEquals(stats.getCount(), 1000);
        assertEquals(stats.getSum(), (double) countTo(1000).stream().mapToInt(i -> i).sum());
        assertEquals(stats.getAverage(), stats.getSum() / stats.getCount());
        assertEquals(stats.getMax(), 1000.0);
        assertEquals(stats.getMin(), 1.0);
    }
}
 
Example #3
Source File: RegistryTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void gauges() {
  Registry r = newRegistry(true, 10000);
  r.gauge(r.createId("foo", "a", "1")).set(1.0);
  r.gauge(r.createId("foo", "a", "2")).set(2.0);
  r.gauge(r.createId("bar")).set(7.0);

  Assertions.assertEquals(3, r.gauges().count());

  final DoubleSummaryStatistics valueSummary = r.gauges()
      .filter(Functions.nameEquals("foo"))
      .collect(Collectors.summarizingDouble(Gauge::value));
  Assertions.assertEquals(2, valueSummary.getCount());
  Assertions.assertEquals(3.0, valueSummary.getSum(), 1e-12);
  Assertions.assertEquals(1.5, valueSummary.getAverage(), 1e-12);
}
 
Example #4
Source File: CollectAndSummaryStatisticsTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleStatistics() {
    List<DoubleSummaryStatistics> instances = new ArrayList<>();
    instances.add(countTo(1000).stream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).stream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).stream().mapToDouble(i -> i).collect(DoubleSummaryStatistics::new,
                                                                     DoubleSummaryStatistics::accept,
                                                                     DoubleSummaryStatistics::combine));
    instances.add(countTo(1000).parallelStream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).collect(DoubleSummaryStatistics::new,
                                                                             DoubleSummaryStatistics::accept,
                                                                             DoubleSummaryStatistics::combine));

    for (DoubleSummaryStatistics stats : instances) {
        assertEquals(stats.getCount(), 1000);
        assertEquals(stats.getSum(), (double) countTo(1000).stream().mapToInt(i -> i).sum());
        assertEquals(stats.getAverage(), stats.getSum() / stats.getCount());
        assertEquals(stats.getMax(), 1000.0);
        assertEquals(stats.getMin(), 1.0);
    }
}
 
Example #5
Source File: CLI.java    From SLP-Core with MIT License 6 votes vote down vote up
private static void test() {
	File inDir = getTestFile();
	File counterFile = getCounterFile();
	if (inDir == null || !inDir.exists()) {
		exit("Test path does not exist: " + getArg(TEST));
	} else if (counterFile == null || !counterFile.exists()) {
		exit("Counter file to use not found: " + getArg(COUNTER));
	}
	
	Stream<Pair<File, List<List<Double>>>> fileProbs = modelRunner.modelDirectory(inDir);
	int[] fileCount = { 0 };
	DoubleSummaryStatistics stats = modelRunner.getStats(
			fileProbs.peek(f -> Writer.writeEntropies(lexerRunner, f))
			.peek(f -> fileCount[0]++));
	System.out.printf("Testing complete, modeled %d files with %d tokens yielding average entropy:\t%.4f\n",
			fileCount[0], stats.getCount(), stats.getAverage());
}
 
Example #6
Source File: CollectAndSummaryStatisticsTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleStatistics() {
    List<DoubleSummaryStatistics> instances = new ArrayList<>();
    instances.add(countTo(1000).stream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).stream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).stream().mapToDouble(i -> i).collect(DoubleSummaryStatistics::new,
                                                                     DoubleSummaryStatistics::accept,
                                                                     DoubleSummaryStatistics::combine));
    instances.add(countTo(1000).parallelStream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).collect(DoubleSummaryStatistics::new,
                                                                             DoubleSummaryStatistics::accept,
                                                                             DoubleSummaryStatistics::combine));

    for (DoubleSummaryStatistics stats : instances) {
        assertEquals(stats.getCount(), 1000);
        assertEquals(stats.getSum(), (double) countTo(1000).stream().mapToInt(i -> i).sum());
        assertEquals(stats.getAverage(), stats.getSum() / stats.getCount());
        assertEquals(stats.getMax(), 1000.0);
        assertEquals(stats.getMin(), 1.0);
    }
}
 
Example #7
Source File: NumericStreams.java    From Java-11-Cookbook-Second-Edition with MIT License 6 votes vote down vote up
private static void summary() {

        IntSummaryStatistics iss = IntStream.empty().summaryStatistics();
        System.out.println(iss);  //IntSummaryStatistics{count=0, sum=0, min=2147483647, average=0.000000, max=-2147483648}
        iss = IntStream.range(1, 3).summaryStatistics();
        System.out.println(iss);  //IntSummaryStatistics{count=2, sum=3, min=1, average=1.500000, max=2}

        LongSummaryStatistics lss = LongStream.empty().summaryStatistics();
        System.out.println(lss);  //LongSummaryStatistics{count=0, sum=0, min=9223372036854775807, average=0.000000, max=-9223372036854775808}
        lss = LongStream.range(1, 3).summaryStatistics();
        System.out.println(lss);  //LongSummaryStatistics{count=2, sum=3, min=1, average=1.500000, max=2}

        DoubleSummaryStatistics dss = DoubleStream.empty().summaryStatistics();
        System.out.println(dss);  //DoubleSummaryStatistics{count=0, sum=0.000000, min=Infinity, average=0.000000, max=-Infinity}
        dss = DoubleStream.of(1, 2).summaryStatistics();
        System.out.println(dss);  //DoubleSummaryStatistics{count=2, sum=3.000000, min=1.000000, average=1.500000, max=2.000000}

        System.out.println(Integer.MAX_VALUE);  //prints:  2147483647
        System.out.println(Integer.MIN_VALUE);  //prints: -2147483648
        System.out.println(Long.MAX_VALUE);  //prints:  9223372036854775807
        System.out.println(Long.MIN_VALUE);  //prints: -9223372036854775808
        System.out.println(Double.MAX_VALUE);  //prints: 1.7976931348623157E308
        System.out.println(Double.MIN_VALUE);  //prints: 4.9E-324
    }
 
Example #8
Source File: CollectAndSummaryStatisticsTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleStatistics() {
    List<DoubleSummaryStatistics> instances = new ArrayList<>();
    instances.add(countTo(1000).stream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).stream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).stream().mapToDouble(i -> i).collect(DoubleSummaryStatistics::new,
                                                                     DoubleSummaryStatistics::accept,
                                                                     DoubleSummaryStatistics::combine));
    instances.add(countTo(1000).parallelStream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).collect(DoubleSummaryStatistics::new,
                                                                             DoubleSummaryStatistics::accept,
                                                                             DoubleSummaryStatistics::combine));

    for (DoubleSummaryStatistics stats : instances) {
        assertEquals(stats.getCount(), 1000);
        assertEquals(stats.getSum(), (double) countTo(1000).stream().mapToInt(i -> i).sum());
        assertEquals(stats.getAverage(), stats.getSum() / stats.getCount());
        assertEquals(stats.getMax(), 1000.0);
        assertEquals(stats.getMin(), 1.0);
    }
}
 
Example #9
Source File: ModelRunner.java    From SLP-Core with MIT License 5 votes vote down vote up
private void logCompletionProgress(List<Completion> completions) {
	DoubleSummaryStatistics stats = completions.stream().skip(1)
			.map(Completion::getRank)
			.mapToDouble(ModelRunner::toMRR)
			.summaryStatistics();
	long prevCount = this.modelStats[0];
	this.modelStats[0] += stats.getCount();
	this.mrr += stats.getSum();
	if (this.modelStats[0] / this.MODEL_PRINT_INTERVAL > prevCount / this.MODEL_PRINT_INTERVAL
			&& this.modelStats[1] != 0) {
		System.out.printf("Predicting: %dK tokens processed in %ds, avg. MRR: %.4f\n",
				Math.round(this.modelStats[0]/1e3),
				(System.currentTimeMillis() + this.modelStats[1])/1000, this.mrr/this.modelStats[0]);
	}
}
 
Example #10
Source File: SummaryStatisticsTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void testDoubleStatistics() {
    List<DoubleSummaryStatistics> instances = new ArrayList<>();
    instances.add(countTo(1000).stream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).stream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).parallelStream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).summaryStatistics());

    for (DoubleSummaryStatistics stats : instances) {
        assertEquals(stats.getCount(), 1000);
        assertEquals(stats.getSum(), (double) countTo(1000).stream().mapToInt(i -> i).sum());
        assertEquals(stats.getMax(), 1000.0);
        assertEquals(stats.getMin(), 1.0);
    }
}
 
Example #11
Source File: SummaryStatisticsTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testDoubleStatistics() {
    List<DoubleSummaryStatistics> instances = new ArrayList<>();
    instances.add(countTo(1000).stream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).stream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).parallelStream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).summaryStatistics());

    for (DoubleSummaryStatistics stats : instances) {
        assertEquals(stats.getCount(), 1000);
        assertEquals(stats.getSum(), (double) countTo(1000).stream().mapToInt(i -> i).sum());
        assertEquals(stats.getMax(), 1000.0);
        assertEquals(stats.getMin(), 1.0);
    }
}
 
Example #12
Source File: SummaryStatisticsTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void testDoubleStatistics() {
    List<DoubleSummaryStatistics> instances = new ArrayList<>();
    instances.add(countTo(1000).stream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).stream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).parallelStream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).summaryStatistics());

    for (DoubleSummaryStatistics stats : instances) {
        assertEquals(stats.getCount(), 1000);
        assertEquals(stats.getSum(), (double) countTo(1000).stream().mapToInt(i -> i).sum());
        assertEquals(stats.getMax(), 1000.0);
        assertEquals(stats.getMin(), 1.0);
    }
}
 
Example #13
Source File: DoubleSummaryStatisticsTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void test_getSum() {
    DoubleSummaryStatistics dss1 = getDoubleSummaryStatisticsData1();
    assertEquals(148.4, dss1.getSum());

    dss1.accept(Double.NaN);
    assertEquals(Double.NaN, dss1.getSum());
}
 
Example #14
Source File: SummaryStatisticsTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void testDoubleStatistics() {
    List<DoubleSummaryStatistics> instances = new ArrayList<>();
    instances.add(countTo(1000).stream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).stream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).parallelStream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).summaryStatistics());

    for (DoubleSummaryStatistics stats : instances) {
        assertEquals(stats.getCount(), 1000);
        assertEquals(stats.getSum(), (double) countTo(1000).stream().mapToInt(i -> i).sum());
        assertEquals(stats.getMax(), 1000.0);
        assertEquals(stats.getMin(), 1.0);
    }
}
 
Example #15
Source File: SummaryStatisticsTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void testDoubleStatistics() {
    List<DoubleSummaryStatistics> instances = new ArrayList<>();
    instances.add(countTo(1000).stream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).stream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).parallelStream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).summaryStatistics());

    for (DoubleSummaryStatistics stats : instances) {
        assertEquals(stats.getCount(), 1000);
        assertEquals(stats.getSum(), (double) countTo(1000).stream().mapToInt(i -> i).sum());
        assertEquals(stats.getMax(), 1000.0);
        assertEquals(stats.getMin(), 1.0);
    }
}
 
Example #16
Source File: CollectAndSummaryStatisticsTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testDoubleCollectNull() {
    checkNPE(() -> DoubleStream.of(1).collect(null,
                                            DoubleSummaryStatistics::accept,
                                            DoubleSummaryStatistics::combine));
    checkNPE(() -> DoubleStream.of(1).collect(DoubleSummaryStatistics::new,
                                            null,
                                            DoubleSummaryStatistics::combine));
    checkNPE(() -> DoubleStream.of(1).collect(DoubleSummaryStatistics::new,
                                              DoubleSummaryStatistics::accept,
                                              null));
}
 
Example #17
Source File: DoubleSummaryStatisticsTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void test_getAverage() {
    DoubleSummaryStatistics dss1 = getDoubleSummaryStatisticsData1();
    assertEquals(21.2, dss1.getAverage(), 1E-6);

    dss1.accept(Double.NaN);
    assertEquals(Double.NaN, dss1.getAverage());
}
 
Example #18
Source File: EmployeeTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void whenApplySummaryStatistics_thenGetBasicStats() {
    DoubleSummaryStatistics stats = empList.stream()
      .mapToDouble(Employee::getSalary)
      .summaryStatistics();

    assertEquals(stats.getCount(), 3);
    assertEquals(stats.getSum(), 600000.0, 0);
    assertEquals(stats.getMin(), 100000.0, 0);
    assertEquals(stats.getMax(), 300000.0, 0);
    assertEquals(stats.getAverage(), 200000.0, 0);
}
 
Example #19
Source File: CategoricalMatcher.java    From JImageHash with MIT License 5 votes vote down vote up
public void printClusterInfo(int minImagesInCluster) {
	for (Entry<Integer, DoubleSummaryStatistics> entry : clusterQuality.entrySet()) {
		if (entry.getValue().getCount() >= minImagesInCluster) {
			System.out
					.println("Category: " + entry.getKey() + " Average Distance: " + entry.getValue().getAverage());
		}
	}
}
 
Example #20
Source File: RegistryTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void maxGauge() {
  Registry r = newRegistry(true, 10000);
  r.maxGauge("foo").set(1.0);
  r.maxGauge("foo").set(3.0);
  r.maxGauge("foo").set(2.0);

  final DoubleSummaryStatistics valueSummary = r.gauges()
      .filter(Functions.nameEquals("foo"))
      .collect(Collectors.summarizingDouble(Gauge::value));
  Assertions.assertEquals(1, valueSummary.getCount());
  Assertions.assertEquals(3.0, valueSummary.getSum(), 1e-12);
}
 
Example #21
Source File: ModelRunner.java    From SLP-Core with MIT License 5 votes vote down vote up
private void logModelingProgress(List<Double> modeled) {
	DoubleSummaryStatistics stats = modeled.stream().skip(1)
			.mapToDouble(Double::doubleValue).summaryStatistics();
	long prevCount = this.modelStats[0];
	this.modelStats[0] += stats.getCount();
	this.ent += stats.getSum();
	if (this.modelStats[0] / this.MODEL_PRINT_INTERVAL > prevCount / this.MODEL_PRINT_INTERVAL
			&& this.modelStats[1] != 0) {
		System.out.printf("Modeling: %dK tokens processed in %ds, avg. entropy: %.4f\n",
				Math.round(this.modelStats[0]/1e3),
				(System.currentTimeMillis() + this.modelStats[1])/1000, this.ent/this.modelStats[0]);
	}
}
 
Example #22
Source File: CLI.java    From SLP-Core with MIT License 5 votes vote down vote up
private static void trainPredict() {
	trainModel();
	File testDir = getTestFile();
	Stream<Pair<File, List<List<Double>>>> fileMRRs = modelRunner.predictDirectory(testDir);
	int[] fileCount = { 0 };
	DoubleSummaryStatistics stats = modelRunner.getStats(
			fileMRRs.peek(f -> Writer.writeEntropies(lexerRunner, f))
			.peek(f -> fileCount[0]++));
	System.out.printf("Testing complete, modeled %d files with %d tokens yielding average MRR:\t%.4f\n",
			fileCount[0], stats.getCount(), stats.getAverage());
}
 
Example #23
Source File: Java8CollectorsUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void whenSummarizing_shouldSummarize() throws Exception {
    final DoubleSummaryStatistics result = givenList.stream().collect(summarizingDouble(String::length));

    assertThat(result.getAverage()).isEqualTo(2);
    assertThat(result.getCount()).isEqualTo(4);
    assertThat(result.getMax()).isEqualTo(3);
    assertThat(result.getMin()).isEqualTo(1);
    assertThat(result.getSum()).isEqualTo(8);
}
 
Example #24
Source File: DoubleSummary.java    From jenetics with Apache License 2.0 5 votes vote down vote up
/**
 * Return a new value object of the statistical summary, currently
 * represented by the {@code statistics} object.
 *
 * @param statistics the creating (mutable) statistics class
 * @return the statistical moments
 */
public static DoubleSummary of(final DoubleSummaryStatistics statistics) {
	return new DoubleSummary(
		statistics.getCount(),
		statistics.getMin(),
		statistics.getMax(),
		statistics.getSum(),
		statistics.getAverage()
	);
}
 
Example #25
Source File: DoubleSummaryStatisticsTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void test_empty() {
    DoubleSummaryStatistics dss = new DoubleSummaryStatistics();
    assertEquals(0, dss.getCount());
    assertEquals(0.0d, dss.getSum());
    assertEquals(0.0d, dss.getAverage());
    assertEquals(Double.POSITIVE_INFINITY, dss.getMin());
    assertEquals(Double.NEGATIVE_INFINITY, dss.getMax());
}
 
Example #26
Source File: SummaryStatisticsTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testDoubleStatistics() {
    List<DoubleSummaryStatistics> instances = new ArrayList<>();
    instances.add(countTo(1000).stream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).stream().mapToDouble(i -> i).summaryStatistics());
    instances.add(countTo(1000).parallelStream().collect(Collectors.summarizingDouble(i -> i)));
    instances.add(countTo(1000).parallelStream().mapToDouble(i -> i).summaryStatistics());

    for (DoubleSummaryStatistics stats : instances) {
        assertEquals(stats.getCount(), 1000);
        assertEquals(stats.getSum(), (double) countTo(1000).stream().mapToInt(i -> i).sum());
        assertEquals(stats.getMax(), 1000.0);
        assertEquals(stats.getMin(), 1.0);
    }
}
 
Example #27
Source File: DoubleSummaryStatisticsTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void test_getMin() {
    DoubleSummaryStatistics dss1 = getDoubleSummaryStatisticsData1();
    assertEquals(-53.4d, dss1.getMin());

    dss1.accept(Double.NaN);
    assertEquals(Double.NaN, dss1.getMin());
}
 
Example #28
Source File: DoubleSummaryStatisticsTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void test_combine() {
    DoubleSummaryStatistics dss1 = getDoubleSummaryStatisticsData2();
    DoubleSummaryStatistics dssCombined = getDoubleSummaryStatisticsData1();
    dssCombined.combine(dss1);
    assertEquals(12, dssCombined.getCount());
    assertEquals(164.4d, dssCombined.getSum());
    assertEquals(100.0d, dssCombined.getMax());
    assertEquals(-53.4d, dssCombined.getMin());
    assertEquals(13.7, dssCombined.getAverage(), 1E-6);
}
 
Example #29
Source File: DoubleSummaryTest.java    From jenetics with Apache License 2.0 5 votes vote down vote up
@Override
protected Factory<DoubleSummary> factory() {
	return () -> {
		final Random random = RandomRegistry.random();

		final DoubleSummaryStatistics statistics = new DoubleSummaryStatistics();
		IntStream.range(0, 100)
			.mapToDouble(i -> random.nextDouble())
			.forEach(statistics);

		return DoubleSummary.of(statistics);
	};
}
 
Example #30
Source File: CollectAndSummaryStatisticsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void testDoubleCollectNull() {
    checkNPE(() -> DoubleStream.of(1).collect(null,
                                            DoubleSummaryStatistics::accept,
                                            DoubleSummaryStatistics::combine));
    checkNPE(() -> DoubleStream.of(1).collect(DoubleSummaryStatistics::new,
                                            null,
                                            DoubleSummaryStatistics::combine));
    checkNPE(() -> DoubleStream.of(1).collect(DoubleSummaryStatistics::new,
                                              DoubleSummaryStatistics::accept,
                                              null));
}