List of usage examples for java.util.stream DoubleStream generate
public static DoubleStream generate(DoubleSupplier s)
From source file:Main.java
public static void main(String[] args) { DoubleStream i = DoubleStream.generate(new Random()::nextDouble); Stream<Double> o = i.boxed(); o.limit(10).forEach(System.out::println); }
From source file:com.wormsim.tracking.ChangingDoubleInstance.java
/** * Returns the mean of the squares of the most recently collected data that * has not yet formed a checkpoint./*from w w w .j ava 2s.c o m*/ * * @return The recent mean */ @Override public final double getRecentSquareMean() { final TDoubleIterator iter = history.iterator(); final double[] total = new double[] { 0.0 }; DoubleStream.generate(() -> iter.next()).peek((d) -> { total[0] += FastMath.pow(d, 2); }).anyMatch((d) -> !iter.hasNext()); return total[0] / (history.size()); }
From source file:com.wormsim.tracking.ChangingDoubleInstance.java
/** * Returns the variance of the most recently collected data that has not yet * formed a checkpoint.// w w w . j a v a 2s . c om * * @return The recent variance */ @Override public final double getRecentVariance() { final double psi_m = history.sum() / history.size(); final TDoubleIterator iter = history.iterator(); final double[] total = new double[] { 0.0 }; DoubleStream.generate(() -> iter.next()).peek((d) -> { total[0] += FastMath.pow(d - psi_m, 2); }).anyMatch((d) -> !iter.hasNext()); return total[0] / (history.size() - 1); }