Class Statistics
- java.lang.Object
-
- org.apache.commons.statistics.descriptive.Statistics
-
final class Statistics extends java.lang.ObjectUtility methods for statistics.- Since:
- 1.1
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.function.DoubleConsumerDOUBLE_NOOPA no-operation double consumer.private static java.lang.StringINCOMPATIBLE_STATISTICSError message for an incompatible statistics.(package private) static java.util.function.IntConsumerINT_NOOPA no-operation int consumer.(package private) static java.util.function.LongConsumerLONG_NOOPA no-operation long consumer.
-
Constructor Summary
Constructors Modifier Constructor Description privateStatistics()No instances.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static <T extends java.util.function.DoubleConsumer>
Tadd(T statistic, double[] values)Add all thevaluesto thestatistic.(package private) static <T extends java.util.function.DoubleConsumer>
Tadd(T statistic, int[] values)Add all thevaluesto thestatistic.(package private) static <T extends java.util.function.DoubleConsumer>
Tadd(T statistic, long[] values)Add all thevaluesto thestatistic.(package private) static voidcheckCombineAssignable(FirstMoment a, FirstMoment b)Check left-hand side argumentaisnullor else the right-hand side argumentbmust be run-time assignable to the same class asaso the statistics can be combined.(package private) static <T extends StatisticResult & StatisticAccumulator<T>>
voidcheckCombineCompatible(T a, T b)Check left-hand side argumentaisnullor else the right-hand side argumentbmust also be non-nullso the statistics can be combined.(package private) static <T extends StatisticResult & StatisticAccumulator<T>>
voidcombine(T a, T b)If the left-hand side argumentais non-null, combine it with the right-hand side argumentb.(package private) static voidcombineMoment(FirstMoment a, FirstMoment b)If the left-hand side argumentais non-null, combine it with the right-hand side argumentb.(package private) static java.util.function.DoubleConsumercompose(java.util.function.DoubleConsumer... consumers)Chain theconsumersinto a single composite consumer.(package private) static java.util.function.IntConsumercompose(java.util.function.IntConsumer... consumers)Chain theconsumersinto a single composite consumer.(package private) static java.util.function.LongConsumercompose(java.util.function.LongConsumer... consumers)Chain theconsumersinto a single composite consumer.(package private) static StatisticResultgetResultAsBigIntegerOrNull(StatisticResult s)Gets the statistic result using theBigIntegervalue.(package private) static StatisticResultgetResultAsDoubleOrNull(StatisticResult s)Gets the statistic result using thedoublevalue.(package private) static StatisticResultgetResultAsIntOrNull(StatisticResult s)Gets the statistic result using theintvalue.(package private) static StatisticResultgetResultAsLongOrNull(StatisticResult s)Gets the statistic result using thelongvalue.(package private) static booleanzeroVariance(double m1, double m2)Returnstrueif the second central momentm2is effectively zero given the magnitude of the first raw momentm1.
-
-
-
Field Detail
-
DOUBLE_NOOP
static final java.util.function.DoubleConsumer DOUBLE_NOOP
A no-operation double consumer. This is exposed for testing.
-
INT_NOOP
static final java.util.function.IntConsumer INT_NOOP
A no-operation int consumer. This is exposed for testing.
-
LONG_NOOP
static final java.util.function.LongConsumer LONG_NOOP
A no-operation long consumer. This is exposed for testing.
-
INCOMPATIBLE_STATISTICS
private static final java.lang.String INCOMPATIBLE_STATISTICS
Error message for an incompatible statistics.- See Also:
- Constant Field Values
-
-
Method Detail
-
add
static <T extends java.util.function.DoubleConsumer> T add(T statistic, double[] values)Add all thevaluesto thestatistic.- Type Parameters:
T- Type of the statistic- Parameters:
statistic- Statistic.values- Values.- Returns:
- the statistic
-
add
static <T extends java.util.function.DoubleConsumer> T add(T statistic, int[] values)Add all thevaluesto thestatistic.- Type Parameters:
T- Type of the statistic- Parameters:
statistic- Statistic.values- Values.- Returns:
- the statistic
-
add
static <T extends java.util.function.DoubleConsumer> T add(T statistic, long[] values)Add all thevaluesto thestatistic.- Type Parameters:
T- Type of the statistic- Parameters:
statistic- Statistic.values- Values.- Returns:
- the statistic
-
add
static <T extends java.util.function.IntConsumer> T add(T statistic, int[] values)Add all thevaluesto thestatistic.- Type Parameters:
T- Type of the statistic- Parameters:
statistic- Statistic.values- Values.- Returns:
- the statistic
-
add
static <T extends java.util.function.LongConsumer> T add(T statistic, long[] values)Add all thevaluesto thestatistic.- Type Parameters:
T- Type of the statistic- Parameters:
statistic- Statistic.values- Values.- Returns:
- the statistic
-
zeroVariance
static boolean zeroVariance(double m1, double m2)Returnstrueif the second central momentm2is effectively zero given the magnitude of the first raw momentm1.This method shares the logic for detecting a zero variance among implementations that divide by the variance (e.g. skewness, kurtosis).
- Parameters:
m1- First raw moment (mean).m2- Second central moment (biased variance).- Returns:
- true if the variance is zero
-
compose
static java.util.function.DoubleConsumer compose(java.util.function.DoubleConsumer... consumers)
Chain theconsumersinto a single composite consumer. Ignore anynullconsumer. Returnsnullif all arguments arenull.- Parameters:
consumers- Consumers.- Returns:
- a composed consumer (or null)
-
compose
static java.util.function.IntConsumer compose(java.util.function.IntConsumer... consumers)
Chain theconsumersinto a single composite consumer. Ignore anynullconsumer. Returnsnullif all arguments arenull.- Parameters:
consumers- Consumers.- Returns:
- a composed consumer (or null)
-
compose
static java.util.function.LongConsumer compose(java.util.function.LongConsumer... consumers)
Chain theconsumersinto a single composite consumer. Ignore anynullconsumer. Returnsnullif all arguments arenull.- Parameters:
consumers- Consumers.- Returns:
- a composed consumer (or null)
-
getResultAsIntOrNull
static StatisticResult getResultAsIntOrNull(StatisticResult s)
Gets the statistic result using theintvalue. Returnnullis the statistic isnull.- Parameters:
s- Statistic.- Returns:
- the result or null
-
getResultAsLongOrNull
static StatisticResult getResultAsLongOrNull(StatisticResult s)
Gets the statistic result using thelongvalue. Returnnullis the statistic isnull.- Parameters:
s- Statistic.- Returns:
- the result or null
-
getResultAsDoubleOrNull
static StatisticResult getResultAsDoubleOrNull(StatisticResult s)
Gets the statistic result using thedoublevalue. Returnnullis the statistic isnull.- Parameters:
s- Statistic.- Returns:
- the result or null
-
getResultAsBigIntegerOrNull
static StatisticResult getResultAsBigIntegerOrNull(StatisticResult s)
Gets the statistic result using theBigIntegervalue. Returnnullis the statistic isnull.- Parameters:
s- Statistic.- Returns:
- the result or null
-
checkCombineCompatible
static <T extends StatisticResult & StatisticAccumulator<T>> void checkCombineCompatible(T a, T b)
Check left-hand side argumentaisnullor else the right-hand side argumentbmust also be non-nullso the statistics can be combined.- Type Parameters:
T-StatisticResultbeing accumulated.- Parameters:
a- LHS.b- RHS.- Throws:
java.lang.IllegalArgumentException- if the objects cannot be combined
-
checkCombineAssignable
static void checkCombineAssignable(FirstMoment a, FirstMoment b)
Check left-hand side argumentaisnullor else the right-hand side argumentbmust be run-time assignable to the same class asaso the statistics can be combined.- Parameters:
a- LHS.b- RHS.- Throws:
java.lang.IllegalArgumentException- if the objects cannot be combined
-
combine
static <T extends StatisticResult & StatisticAccumulator<T>> void combine(T a, T b)
If the left-hand side argumentais non-null, combine it with the right-hand side argumentb.- Type Parameters:
T-StatisticResultbeing accumulated.- Parameters:
a- LHS.b- RHS.
-
combineMoment
static void combineMoment(FirstMoment a, FirstMoment b)
If the left-hand side argumentais non-null, combine it with the right-hand side argumentb. Assumes that the RHS is run-time assignable to the same class as LHS.- Parameters:
a- LHS.b- RHS.- See Also:
checkCombineAssignable(FirstMoment, FirstMoment)
-
-