You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2023/12/23 12:19:28 UTC
(commons-statistics) 05/06: Drop DoubleStatisticAccumulator interface
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-statistics.git
commit 8c2cf0b5fe56410d8c63abe2cdd780112c91d617
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Thu Dec 21 22:04:01 2023 +0000
Drop DoubleStatisticAccumulator interface
All StatisticResult implementations can use the StatisticAccumulator
interface; the argument type for the statistic computation
(int/long/double) is not relevant to the accumulator combine method.
---
.../descriptive/DoubleStatisticAccumulator.java | 35 -----------------
.../statistics/descriptive/DoubleStatistics.java | 2 +-
.../statistics/descriptive/FirstMoment.java | 4 +-
.../statistics/descriptive/GeometricMean.java | 6 +--
.../commons/statistics/descriptive/Kurtosis.java | 6 +--
.../apache/commons/statistics/descriptive/Max.java | 6 +--
.../commons/statistics/descriptive/Mean.java | 6 +--
.../apache/commons/statistics/descriptive/Min.java | 6 +--
.../commons/statistics/descriptive/Product.java | 6 +--
.../commons/statistics/descriptive/Skewness.java | 6 +--
.../statistics/descriptive/StandardDeviation.java | 6 +--
.../apache/commons/statistics/descriptive/Sum.java | 6 +--
.../descriptive/SumOfCubedDeviations.java | 4 +-
.../descriptive/SumOfFourthDeviations.java | 4 +-
.../commons/statistics/descriptive/SumOfLogs.java | 6 +--
.../descriptive/SumOfSquaredDeviations.java | 4 +-
.../statistics/descriptive/SumOfSquares.java | 6 +--
.../commons/statistics/descriptive/Variance.java | 6 +--
.../descriptive/BaseDoubleStatisticTest.java | 44 +++++++++++-----------
.../descriptive/DoubleStatisticsTest.java | 8 ++--
.../descriptive/SumOfCubedDeviationsWrapper.java | 2 +-
.../descriptive/SumOfFourthDeviationsWrapper.java | 2 +-
22 files changed, 73 insertions(+), 108 deletions(-)
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatisticAccumulator.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatisticAccumulator.java
deleted file mode 100644
index d06207c..0000000
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatisticAccumulator.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.statistics.descriptive;
-
-/**
- * A mutable result container that accumulates a {@link DoubleStatistic}.
- *
- * @param <T> {@link DoubleStatistic} being accumulated.
- *
- * @since 1.1
- */
-public interface DoubleStatisticAccumulator<T extends DoubleStatistic> {
-
- /**
- * Combines the state of the {@code other} statistic into this one.
- *
- * @param other Another statistic to be combined.
- * @return {@code this} instance after combining {@code other}.
- */
- T combine(T other);
-}
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatistics.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatistics.java
index 7ae57c8..299f52a 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatistics.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatistics.java
@@ -681,7 +681,7 @@ public final class DoubleStatistics implements DoubleConsumer {
* @param a LHS.
* @param b RHS.
*/
- private static <T extends DoubleStatistic & DoubleStatisticAccumulator<T>> void combine(T a, T b) {
+ private static <T extends DoubleStatistic & StatisticAccumulator<T>> void combine(T a, T b) {
if (a != null) {
a.combine(b);
}
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/FirstMoment.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/FirstMoment.java
index 18d4ed2..5fe08f5 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/FirstMoment.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/FirstMoment.java
@@ -38,10 +38,10 @@ import java.util.function.DoubleConsumer;
* <p><strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
* one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel implementation of {@link java.util.stream.Stream#collect Stream.collect()}
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/GeometricMean.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/GeometricMean.java
index f550f8f..64f0647 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/GeometricMean.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/GeometricMean.java
@@ -44,10 +44,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>This instance is not thread safe.</strong>
* If multiple threads access an instance of this class concurrently,
* and at least one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel instance of {@link java.util.stream.Stream#collect Stream.collect()}
@@ -58,7 +58,7 @@ package org.apache.commons.statistics.descriptive;
* @see SumOfLogs
* @since 1.1
*/
-public final class GeometricMean implements DoubleStatistic, DoubleStatisticAccumulator<GeometricMean> {
+public final class GeometricMean implements DoubleStatistic, StatisticAccumulator<GeometricMean> {
/** Count of values that have been added. */
private long n;
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Kurtosis.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Kurtosis.java
index e4c6547..6057a5a 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Kurtosis.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Kurtosis.java
@@ -74,10 +74,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>Note that this instance is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
* one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel instance of {@link java.util.stream.Stream#collect Stream.collect()}
@@ -87,7 +87,7 @@ package org.apache.commons.statistics.descriptive;
* @see <a href="https://en.wikipedia.org/wiki/Kurtosis">Kurtosis (Wikipedia)</a>
* @since 1.1
*/
-public final class Kurtosis implements DoubleStatistic, DoubleStatisticAccumulator<Kurtosis> {
+public final class Kurtosis implements DoubleStatistic, StatisticAccumulator<Kurtosis> {
/** 2, the length limit where the biased skewness is undefined.
* This limit effectively imposes the result m4 / m2^2 = 0 / 0 = NaN when 1 value
* has been added. However note that when more samples are added and the variance
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Max.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Max.java
index 16709da..5ac6ad8 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Max.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Max.java
@@ -32,10 +32,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>This implementation is not thread safe.</strong>
* If multiple threads access an instance of this class concurrently,
* and at least one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel implementation of {@link java.util.stream.Stream#collect Stream.collect()}
@@ -45,7 +45,7 @@ package org.apache.commons.statistics.descriptive;
* @since 1.1
* @see Math#max(double, double)
*/
-public final class Max implements DoubleStatistic, DoubleStatisticAccumulator<Max> {
+public final class Max implements DoubleStatistic, StatisticAccumulator<Max> {
/** Current maximum. */
private double maximum = Double.NEGATIVE_INFINITY;
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Mean.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Mean.java
index f35c07c..1f0e1b6 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Mean.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Mean.java
@@ -50,10 +50,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
* one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel implementation of {@link java.util.stream.Stream#collect Stream.collect()}
@@ -71,7 +71,7 @@ package org.apache.commons.statistics.descriptive;
* @see <a href="https://en.wikipedia.org/wiki/Mean">Mean (Wikipedia)</a>
* @since 1.1
*/
-public final class Mean implements DoubleStatistic, DoubleStatisticAccumulator<Mean> {
+public final class Mean implements DoubleStatistic, StatisticAccumulator<Mean> {
/**
* First moment used to compute the mean.
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Min.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Min.java
index 19f301f..7601f6b 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Min.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Min.java
@@ -32,10 +32,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>This implementation is not thread safe.</strong>
* If multiple threads access an instance of this class concurrently,
* and at least one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel implementation of {@link java.util.stream.Stream#collect Stream.collect()}
@@ -45,7 +45,7 @@ package org.apache.commons.statistics.descriptive;
* @since 1.1
* @see Math#min(double, double)
*/
-public final class Min implements DoubleStatistic, DoubleStatisticAccumulator<Min> {
+public final class Min implements DoubleStatistic, StatisticAccumulator<Min> {
/** Current minimum. */
private double minimum = Double.POSITIVE_INFINITY;
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Product.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Product.java
index 86cfbff..3e656f7 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Product.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Product.java
@@ -30,10 +30,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>This instance is not thread safe.</strong>
* If multiple threads access an instance of this class concurrently,
* and at least one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel instance of {@link java.util.stream.Stream#collect Stream.collect()}
@@ -42,7 +42,7 @@ package org.apache.commons.statistics.descriptive;
*
* @since 1.1
*/
-public final class Product implements DoubleStatistic, DoubleStatisticAccumulator<Product> {
+public final class Product implements DoubleStatistic, StatisticAccumulator<Product> {
/** Product of all values. */
private double productValue = 1;
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Skewness.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Skewness.java
index f948159..383dfe4 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Skewness.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Skewness.java
@@ -76,10 +76,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>Note that this instance is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
* one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel instance of {@link java.util.stream.Stream#collect Stream.collect()}
@@ -89,7 +89,7 @@ package org.apache.commons.statistics.descriptive;
* @see <a href="https://en.wikipedia.org/wiki/Skewness">Skewness (Wikipedia)</a>
* @since 1.1
*/
-public final class Skewness implements DoubleStatistic, DoubleStatisticAccumulator<Skewness> {
+public final class Skewness implements DoubleStatistic, StatisticAccumulator<Skewness> {
/** 2, the length limit where the biased skewness is undefined.
* This limit effectively imposes the result m3 / m2^1.5 = 0 / 0 = NaN when 1 value
* has been added. However note that when more samples are added and the variance
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/StandardDeviation.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/StandardDeviation.java
index 97f0b77..d293bae 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/StandardDeviation.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/StandardDeviation.java
@@ -57,10 +57,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>Note that this instance is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
* one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel instance of {@link java.util.stream.Stream#collect Stream.collect()}
@@ -85,7 +85,7 @@ package org.apache.commons.statistics.descriptive;
* @see Variance
* @since 1.1
*/
-public final class StandardDeviation implements DoubleStatistic, DoubleStatisticAccumulator<StandardDeviation> {
+public final class StandardDeviation implements DoubleStatistic, StatisticAccumulator<StandardDeviation> {
/**
* An instance of {@link SumOfSquaredDeviations}, which is used to
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Sum.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Sum.java
index 08ef6c3..4230336 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Sum.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Sum.java
@@ -30,10 +30,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>This instance is not thread safe.</strong>
* If multiple threads access an instance of this class concurrently,
* and at least one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel instance of {@link java.util.stream.Stream#collect Stream.collect()}
@@ -43,7 +43,7 @@ package org.apache.commons.statistics.descriptive;
* @since 1.1
* @see org.apache.commons.numbers.core.Sum
*/
-public final class Sum implements DoubleStatistic, DoubleStatisticAccumulator<Sum> {
+public final class Sum implements DoubleStatistic, StatisticAccumulator<Sum> {
/** {@link org.apache.commons.numbers.core.Sum Sum} used to compute the sum. */
private final org.apache.commons.numbers.core.Sum delegate =
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfCubedDeviations.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfCubedDeviations.java
index e58610f..bcc5565 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfCubedDeviations.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfCubedDeviations.java
@@ -44,10 +44,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
* one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel implementation of {@link java.util.stream.Stream#collect Stream.collect()}
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfFourthDeviations.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfFourthDeviations.java
index b0bc155..8f379c4 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfFourthDeviations.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfFourthDeviations.java
@@ -48,10 +48,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
* one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel implementation of {@link java.util.stream.Stream#collect Stream.collect()}
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfLogs.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfLogs.java
index b524138..aaf9664 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfLogs.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfLogs.java
@@ -42,10 +42,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>This instance is not thread safe.</strong>
* If multiple threads access an instance of this class concurrently,
* and at least one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel instance of {@link java.util.stream.Stream#collect Stream.collect()}
@@ -56,7 +56,7 @@ package org.apache.commons.statistics.descriptive;
* @see Math#log(double)
* @since 1.1
*/
-public final class SumOfLogs implements DoubleStatistic, DoubleStatisticAccumulator<SumOfLogs> {
+public final class SumOfLogs implements DoubleStatistic, StatisticAccumulator<SumOfLogs> {
/** {@link org.apache.commons.numbers.core.Sum Sum} used to compute the sum. */
private final org.apache.commons.numbers.core.Sum delegate =
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfSquaredDeviations.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfSquaredDeviations.java
index ed0f979..1a3d7d7 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfSquaredDeviations.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfSquaredDeviations.java
@@ -33,10 +33,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
* one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel implementation of {@link java.util.stream.Stream#collect Stream.collect()}
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfSquares.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfSquares.java
index 8364a94..9be57d0 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfSquares.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/SumOfSquares.java
@@ -36,10 +36,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>This instance is not thread safe.</strong>
* If multiple threads access an instance of this class concurrently,
* and at least one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel instance of {@link java.util.stream.Stream#collect Stream.collect()}
@@ -48,7 +48,7 @@ package org.apache.commons.statistics.descriptive;
*
* @since 1.1
*/
-public final class SumOfSquares implements DoubleStatistic, DoubleStatisticAccumulator<SumOfSquares> {
+public final class SumOfSquares implements DoubleStatistic, StatisticAccumulator<SumOfSquares> {
/** Sum of squares of all values. */
private double ss;
diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Variance.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Variance.java
index dbb153a..b875a55 100644
--- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Variance.java
+++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Variance.java
@@ -54,10 +54,10 @@ package org.apache.commons.statistics.descriptive;
* <p><strong>Note that this instance is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
* one of the threads invokes the {@link java.util.function.DoubleConsumer#accept(double) accept} or
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method, it must be synchronized externally.
+ * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally.
*
* <p>However, it is safe to use {@link java.util.function.DoubleConsumer#accept(double) accept}
- * and {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * and {@link StatisticAccumulator#combine(StatisticResult) combine}
* as {@code accumulator} and {@code combiner} functions of
* {@link java.util.stream.Collector Collector} on a parallel stream,
* because the parallel instance of {@link java.util.stream.Stream#collect Stream.collect()}
@@ -81,7 +81,7 @@ package org.apache.commons.statistics.descriptive;
* @see StandardDeviation
* @since 1.1
*/
-public final class Variance implements DoubleStatistic, DoubleStatisticAccumulator<Variance> {
+public final class Variance implements DoubleStatistic, StatisticAccumulator<Variance> {
/**
* An instance of {@link SumOfSquaredDeviations}, which is used to
diff --git a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/BaseDoubleStatisticTest.java b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/BaseDoubleStatisticTest.java
index bdda305..a349e2f 100644
--- a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/BaseDoubleStatisticTest.java
+++ b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/BaseDoubleStatisticTest.java
@@ -40,7 +40,7 @@ import org.junit.jupiter.params.provider.MethodSource;
/**
* Abstract base class for statistic tests.
* This supports testing statistics that implement {@link DoubleStatistic} and
- * {@link DoubleStatisticAccumulator}.
+ * {@link StatisticAccumulator}.
*
* <p>This class uses parameterized tests that are repeated for instances of a
* statistic. The statistic is tested using standard finite and non-finite data.
@@ -51,10 +51,10 @@ import org.junit.jupiter.params.provider.MethodSource;
* <ol>
* <li>{@link java.util.function.DoubleConsumer#accept accept}
* <li>{@link java.util.function.DoubleConsumer#accept accept} and
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * {@link StatisticAccumulator#combine(DoubleStatistic) combine}
* <li>{@link #create(double...)}
* <li>{@link #create(double...)} and
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * {@link StatisticAccumulator#combine(DoubleStatistic) combine}
* </ol>
*
* <p>A test implementation has to provide these method implementations:
@@ -107,7 +107,7 @@ import org.junit.jupiter.params.provider.MethodSource;
* @param <S> Statistic type
*/
@TestInstance(Lifecycle.PER_CLASS)
-abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatisticAccumulator<S>> {
+abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & StatisticAccumulator<S>> {
/** An empty {@code double[]}. */
private static final double[] EMPTY = {};
/** The number of random permutations to perform. */
@@ -547,7 +547,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
/**
* Returns {@code true} if the
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * {@link StatisticAccumulator#combine(DoubleStatistic) combine}
* method is symmetric. If {@code true} then the combine will be tested with
* duplicate instances of the statistic, combined in left-to-right and right-to-left;
* the result must have the same statistic value.
@@ -740,10 +740,10 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
* <ol>
* <li>{@link java.util.function.DoubleConsumer#accept accept}
* <li>{@link java.util.function.DoubleConsumer#accept accept} and
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * {@link StatisticAccumulator#combine(DoubleStatistic) combine}
* <li>{@link #create(double...)}
* <li>{@link #create(double...)} and
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * {@link StatisticAccumulator#combine(DoubleStatistic) combine}
* </ol>
*
* <p>To test the {@code combine} method the data is split into approximately even groups
@@ -822,7 +822,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
/**
* Stream the arguments to test the computation of the statistic using the
* {@link java.util.function.DoubleConsumer#accept(double) accept} method for each
- * array, then the {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * array, then the {@link StatisticAccumulator#combine(DoubleStatistic) combine}
* method. The expected value and tolerance are supplied by the implementing class.
*
* @return the stream
@@ -834,7 +834,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
/**
* Stream the arguments to test the computation of the statistic using the
* {@link #create(double...)} method for each array, then the
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method. The
+ * {@link StatisticAccumulator#combine(DoubleStatistic) combine} method. The
* expected value and tolerance are supplied by the implementing class.
*
* @return the stream
@@ -847,7 +847,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
* Stream the arguments to test the computation of the statistic using the
* {@link java.util.function.DoubleConsumer#accept(double) accept} method for each
* element of a parallel stream, then the
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method.
+ * {@link StatisticAccumulator#combine(DoubleStatistic) combine} method.
* The expected value and tolerance are supplied by the implementing class.
*
* <p>Note that this method uses the tolerance from {@link #getToleranceAcceptAndCombine()}.
@@ -861,7 +861,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
/**
* Stream the arguments to test the computation of the statistic using the multiple
* {@code double[]} arrays and the
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method.
+ * {@link StatisticAccumulator#combine(DoubleStatistic) combine} method.
*
* @param tol Test tolerance.
* @param tolCustom Tolerance for any custom test data.
@@ -1015,7 +1015,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
/**
* Test the computation of the statistic using the
* {@link java.util.function.DoubleConsumer#accept(double) accept} method for each
- * array, then the {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * array, then the {@link StatisticAccumulator#combine(DoubleStatistic) combine}
* method.
*/
@ParameterizedTest
@@ -1027,7 +1027,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
/**
* Test the computation of the statistic using the
* {@link java.util.function.DoubleConsumer#accept(double) accept} method for each
- * array, then the {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * array, then the {@link StatisticAccumulator#combine(DoubleStatistic) combine}
* method.
*/
@ParameterizedTest
@@ -1037,7 +1037,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
}
/**
- * Test the {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method
+ * Test the {@link StatisticAccumulator#combine(DoubleStatistic) combine} method
* with an empty instance combined with a non-empty instance.
*/
@ParameterizedTest
@@ -1052,7 +1052,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
}
/**
- * Test the {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method
+ * Test the {@link StatisticAccumulator#combine(DoubleStatistic) combine} method
* with a non-empty instance combined with an empty instance.
*/
@ParameterizedTest
@@ -1070,7 +1070,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
* Test the computation of the statistic using a parallel stream of {@code double}
* values. The accumulator is the
* {@link java.util.function.DoubleConsumer#accept(double) accept} method; the
- * combiner is the {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine}
+ * combiner is the {@link StatisticAccumulator#combine(DoubleStatistic) combine}
* method.
*
* <p>Note: This method is similar to the
@@ -1086,7 +1086,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
final void testAcceptParallelStream(double[] values, double expected, DoubleTolerance tol) {
final double actual = Arrays.stream(values)
.parallel()
- .collect(this::create, DoubleStatistic::accept, DoubleStatisticAccumulator::combine)
+ .collect(this::create, DoubleStatistic::accept, StatisticAccumulator::combine)
.getAsDouble();
TestUtils.assertEquals(expected, actual, tol, () -> statisticName + ": " + format(values));
}
@@ -1095,7 +1095,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
* Test the computation of the statistic using a parallel stream of {@code double[]}
* arrays. The arrays are mapped to a statistic using the {@link #create(double...)}
* method, and the stream reduced using the
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method.
+ * {@link StatisticAccumulator#combine(DoubleStatistic) combine} method.
*
* <p>Note: This method is similar to the
* {@link #testArrayAndCombine(double[][], double, DoubleTolerance)} method and uses
@@ -1110,7 +1110,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
final double actual = Arrays.stream(values)
.parallel()
.map(this::create)
- .reduce(DoubleStatisticAccumulator::combine)
+ .reduce(StatisticAccumulator::combine)
// Return an empty instance if there is no data
.orElseGet(this::create)
.getAsDouble();
@@ -1205,7 +1205,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
/**
* Test the computation of the statistic using an empty instance and the
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method with
+ * {@link StatisticAccumulator#combine(DoubleStatistic) combine} method with
* instances containing single values. Adding statistic instances containing 1 value
* should be the same precision as adding a {@code double} value, although the two
* results are not required to be exactly equal.
@@ -1240,7 +1240,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
/**
* Assert the computation of the statistic using the
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method.
+ * {@link StatisticAccumulator#combine(DoubleStatistic) combine} method.
*
* @param constructor Function to create the statistic.
* @param values Values.
@@ -1319,7 +1319,7 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
/**
* Combine the two statistics. This method asserts the contract of the
- * {@link DoubleStatisticAccumulator#combine(DoubleStatistic) combine} method.
+ * {@link StatisticAccumulator#combine(DoubleStatistic) combine} method.
* The left-hand side (LHS) argument must be returned. The right-hand side (RHS) must
* be unchanged by the operation.
*
diff --git a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/DoubleStatisticsTest.java b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/DoubleStatisticsTest.java
index 9f64644..576e435 100644
--- a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/DoubleStatisticsTest.java
+++ b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/DoubleStatisticsTest.java
@@ -187,20 +187,20 @@ class DoubleStatisticsTest {
* @param constructor Constructor for an empty object.
* @param arrayConstructor Constructor using an array of values.
*/
- private static <T extends DoubleStatistic & DoubleStatisticAccumulator<T>> void addExpected(Statistic statistic,
+ private static <T extends DoubleStatistic & StatisticAccumulator<T>> void addExpected(Statistic statistic,
Supplier<T> constructor, Function<double[], T> arrayConstructor) {
final List<ExpectedResult> results = new ArrayList<>();
for (final TestData d : testData) {
// Stream values
final double e1 = d.stream()
.map(values -> Statistics.add(constructor.get(), values))
- .reduce(DoubleStatisticAccumulator::combine)
+ .reduce(StatisticAccumulator::combine)
.orElseThrow(IllegalStateException::new)
.getAsDouble();
// Create from array
final double e2 = d.stream()
.map(arrayConstructor)
- .reduce(DoubleStatisticAccumulator::combine)
+ .reduce(StatisticAccumulator::combine)
.orElseThrow(IllegalStateException::new)
.getAsDouble();
// Check that there is a finite value to compute during testing
@@ -574,7 +574,7 @@ class DoubleStatisticsTest {
* @param setter Option setter.
* @return the number of unique results
*/
- private static <T extends DoubleStatistic & DoubleStatisticAccumulator<T>> int addBooleanOptionCase(
+ private static <T extends DoubleStatistic & StatisticAccumulator<T>> int addBooleanOptionCase(
Stream.Builder<Arguments> builder, double[] values, Statistic statistic,
Function<double[], T> arrayConstructor, BiConsumer<T, Boolean> setter) {
final T stat = arrayConstructor.apply(values);
diff --git a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/SumOfCubedDeviationsWrapper.java b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/SumOfCubedDeviationsWrapper.java
index e60eb8a..47e4706 100644
--- a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/SumOfCubedDeviationsWrapper.java
+++ b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/SumOfCubedDeviationsWrapper.java
@@ -20,7 +20,7 @@ package org.apache.commons.statistics.descriptive;
* Wrapper for {@link SumOfCubedDeviations} to allow testing as a statistic.
*/
final class SumOfCubedDeviationsWrapper implements
- DoubleStatistic, DoubleStatisticAccumulator<SumOfCubedDeviationsWrapper> {
+ DoubleStatistic, StatisticAccumulator<SumOfCubedDeviationsWrapper> {
private final SumOfCubedDeviations delegate;
diff --git a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/SumOfFourthDeviationsWrapper.java b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/SumOfFourthDeviationsWrapper.java
index b540a2d..4f3dbf7 100644
--- a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/SumOfFourthDeviationsWrapper.java
+++ b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/SumOfFourthDeviationsWrapper.java
@@ -20,7 +20,7 @@ package org.apache.commons.statistics.descriptive;
* Wrapper for {@link SumOfFourthDeviations} to allow testing as a statistic.
*/
final class SumOfFourthDeviationsWrapper implements
- DoubleStatistic, DoubleStatisticAccumulator<SumOfFourthDeviationsWrapper> {
+ DoubleStatistic, StatisticAccumulator<SumOfFourthDeviationsWrapper> {
private final SumOfFourthDeviations delegate;