Search in sources :

Example 31 with DoubleSummaryStatistics

use of java.util.DoubleSummaryStatistics in project tutorials by eugenp.

the class EmployeeTest method whenApplySummaryStatistics_thenGetBasicStats.

@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);
}
Also used : DoubleSummaryStatistics(java.util.DoubleSummaryStatistics) Test(org.junit.Test)

Example 32 with DoubleSummaryStatistics

use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.

the class AbstractRichIterableTestCase method summarizeFloat.

@Test
public void summarizeFloat() {
    RichIterable<Integer> objects = this.newWith(1, 2, 3);
    DoubleSummaryStatistics expected = objects.summarizeFloat(Integer::floatValue);
    Assert.assertEquals(6.0d, expected.getSum(), 0.0);
    Assert.assertEquals(3, expected.getCount());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DoubleSummaryStatistics(java.util.DoubleSummaryStatistics) Test(org.junit.Test)

Example 33 with DoubleSummaryStatistics

use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.

the class RichIterable method summarizeDouble.

/**
 * Returns the result of summarizing the value returned from applying the DoubleFunction to
 * each element of the iterable.
 * <p>
 * <pre>
 * DoubleSummaryStatistics stats =
 *     Lists.mutable.with(1, 2, 3).summarizeDouble(Integer::doubleValue);
 * </pre>
 *
 * @since 8.0
 */
default DoubleSummaryStatistics summarizeDouble(DoubleFunction<? super T> function) {
    DoubleSummaryStatistics stats = new DoubleSummaryStatistics();
    this.each(each -> stats.accept(function.doubleValueOf(each)));
    return stats;
}
Also used : DoubleSummaryStatistics(java.util.DoubleSummaryStatistics)

Example 34 with DoubleSummaryStatistics

use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.

the class InternalArrayIterate method summarizeFloat.

/**
 * @since 8.0
 */
public static <T> DoubleSummaryStatistics summarizeFloat(T[] items, int size, FloatFunction<? super T> function) {
    DoubleSummaryStatistics stats = new DoubleSummaryStatistics();
    for (int i = 0; i < size; i++) {
        T item = items[i];
        stats.accept((double) function.floatValueOf(item));
    }
    return stats;
}
Also used : DoubleSummaryStatistics(java.util.DoubleSummaryStatistics)

Example 35 with DoubleSummaryStatistics

use of java.util.DoubleSummaryStatistics in project eclipse-collections by eclipse.

the class SerializableDoubleSummaryStatisticsTest method valuesEqual.

@Test
public void valuesEqual() {
    SerializableDoubleSummaryStatistics with = SerializableDoubleSummaryStatistics.with(1.0, 2.0, 3.0);
    DoubleSummaryStatistics without = new DoubleSummaryStatistics();
    without.accept(1.0d);
    without.accept(2.0d);
    without.accept(3.0d);
    Assert.assertTrue(with.valuesEqual(without));
}
Also used : DoubleSummaryStatistics(java.util.DoubleSummaryStatistics) Test(org.junit.Test)

Aggregations

DoubleSummaryStatistics (java.util.DoubleSummaryStatistics)39 Arrays (java.util.Arrays)9 List (java.util.List)9 Test (org.junit.Test)9 Layer (com.simiacryptus.mindseye.lang.Layer)8 Tensor (com.simiacryptus.mindseye.lang.Tensor)8 LongSummaryStatistics (java.util.LongSummaryStatistics)8 IntStream (java.util.stream.IntStream)8 Nonnull (javax.annotation.Nonnull)8 Nullable (javax.annotation.Nullable)8 TrainingMonitor (com.simiacryptus.mindseye.opt.TrainingMonitor)7 Map (java.util.Map)6 LoggingWrapperLayer (com.simiacryptus.mindseye.layers.java.LoggingWrapperLayer)5 MonitoringWrapperLayer (com.simiacryptus.mindseye.layers.java.MonitoringWrapperLayer)5 StochasticComponent (com.simiacryptus.mindseye.layers.java.StochasticComponent)5 DAGNetwork (com.simiacryptus.mindseye.network.DAGNetwork)5 DAGNode (com.simiacryptus.mindseye.network.DAGNode)5 Step (com.simiacryptus.mindseye.opt.Step)5 MonitoredObject (com.simiacryptus.util.MonitoredObject)5 DoubleStatistics (com.simiacryptus.util.data.DoubleStatistics)5