List of usage examples for java.util Random doubles
public DoubleStream doubles()
From source file:org.jenetics.stat.MinMaxTest.java
@Test public void acceptNormalMinMax() { final Random random = RandomRegistry.getRandom(); final double[] numbers = random.doubles().limit(1000).toArray(); final MinMax<Double> minMax = MinMax.of(); Arrays.stream(numbers).mapToObj(Double::new).forEach(minMax); Assert.assertEquals(minMax.getMin(), StatUtils.min(numbers)); Assert.assertEquals(minMax.getMax(), StatUtils.max(numbers)); }
From source file:org.jenetics.stat.MinMaxTest.java
@Test public void acceptReverseMinMax() { final Random random = RandomRegistry.getRandom(); final double[] numbers = random.doubles().limit(1000).toArray(); final MinMax<Double> minMax = MinMax.of((a, b) -> b.compareTo(a)); Arrays.stream(numbers).mapToObj(Double::new).forEach(minMax); Assert.assertEquals(minMax.getMin(), StatUtils.max(numbers)); Assert.assertEquals(minMax.getMax(), StatUtils.min(numbers)); }
From source file:org.jenetics.stat.MinMaxTest.java
@Test public void toMinMaxNormal() { final Random random = RandomRegistry.getRandom(); final double[] numbers = random.doubles().limit(1000).toArray(); final MinMax<Double> minMax = Arrays.stream(numbers).mapToObj(Double::new).collect(MinMax.toMinMax()); Assert.assertEquals(minMax.getMin(), StatUtils.min(numbers)); Assert.assertEquals(minMax.getMax(), StatUtils.max(numbers)); }
From source file:org.jenetics.stat.MinMaxTest.java
@Test public void toMinMaxReverse() { final Random random = RandomRegistry.getRandom(); final double[] numbers = random.doubles().limit(1000).toArray(); final MinMax<Double> minMax = Arrays.stream(numbers).mapToObj(Double::new) .collect(MinMax.toMinMax((a, b) -> b.compareTo(a))); Assert.assertEquals(minMax.getMin(), StatUtils.max(numbers)); Assert.assertEquals(minMax.getMax(), StatUtils.min(numbers)); }
From source file:org.terracotta.statistics.derived.histogram.HistogramFittingTest.java
private double[] flatHistogramFit(long seed) { Random rndm = new Random(seed); Histogram hist = histogram(bias, bars, rndm.doubles().map(d -> d * 1000.0).limit(100000)); return fit(hist, PolynomialCurveFitter.create(1)); }