Class LongStatistics.Builder
- java.lang.Object
-
- org.apache.commons.statistics.descriptive.LongStatistics.Builder
-
- Enclosing class:
- LongStatistics
public static final class LongStatistics.Builder extends java.lang.Object
A builder forLongStatistics
.
-
-
Field Summary
Fields Modifier and Type Field Description private StatisticsConfiguration
config
Configuration options for computation of statistics.private java.util.function.Function<long[],LongMax>
max
TheLongMax
constructor.private java.util.function.Function<long[],LongMin>
min
TheLongMin
constructor.private java.util.function.Function<long[],FirstMoment>
moment
The moment constructor.private int
momentOrder
The order of the moment.private static long[]
NO_VALUES
An empty double array.private java.util.function.Function<long[],Product>
product
TheProduct
constructor.private java.util.function.Function<long[],LongSum>
sum
TheLongSum
constructor.private java.util.function.Function<long[],SumOfLogs>
sumOfLogs
TheSumOfLogs
constructor.private java.util.function.Function<long[],LongSumOfSquares>
sumOfSquares
TheLongSumOfSquares
constructor.
-
Constructor Summary
Constructors Constructor Description Builder()
Create an instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) LongStatistics.Builder
add(Statistic statistic)
Add the statistic to the statistics to compute.LongStatistics
build()
Builds aLongStatistics
instance.LongStatistics
build(long... values)
Builds aLongStatistics
instance using the inputvalues
.private static <T> T
create(java.util.function.Function<long[],T> constructor, long[] values)
Creates the object from thevalues
.private void
createMoment(int order)
Creates the moment constructor for the specifiedorder
, e.g.LongStatistics.Builder
setConfiguration(StatisticsConfiguration v)
Sets the statistics configuration options for computation of statistics.
-
-
-
Field Detail
-
NO_VALUES
private static final long[] NO_VALUES
An empty double array.
-
moment
private java.util.function.Function<long[],FirstMoment> moment
The moment constructor. May return any instance ofFirstMoment
.
-
sumOfSquares
private java.util.function.Function<long[],LongSumOfSquares> sumOfSquares
TheLongSumOfSquares
constructor.
-
sumOfLogs
private java.util.function.Function<long[],SumOfLogs> sumOfLogs
TheSumOfLogs
constructor.
-
momentOrder
private int momentOrder
The order of the moment. It corresponds to the power computed by theFirstMoment
instance constructed bymoment
. This should only be increased from the default of zero (corresponding to no moment computation).
-
config
private StatisticsConfiguration config
Configuration options for computation of statistics.
-
-
Method Detail
-
add
LongStatistics.Builder add(Statistic statistic)
Add the statistic to the statistics to compute.- Parameters:
statistic
- Statistic to compute.- Returns:
this
instance
-
createMoment
private void createMoment(int order)
Creates the moment constructor for the specifiedorder
, e.g. order=3 is sum of cubed deviations.- Parameters:
order
- Order.
-
setConfiguration
public LongStatistics.Builder setConfiguration(StatisticsConfiguration v)
Sets the statistics configuration options for computation of statistics.- Parameters:
v
- Value.- Returns:
- the builder
- Throws:
java.lang.NullPointerException
- if the value is null
-
build
public LongStatistics build()
Builds aLongStatistics
instance.- Returns:
LongStatistics
instance.
-
build
public LongStatistics build(long... values)
Builds aLongStatistics
instance using the inputvalues
.Note:
LongStatistics
computed usingaccept
may be different from this instance.- Parameters:
values
- Values.- Returns:
LongStatistics
instance.
-
create
private static <T> T create(java.util.function.Function<long[],T> constructor, long[] values)
Creates the object from thevalues
.- Type Parameters:
T
- object type- Parameters:
constructor
- Constructor.values
- Values- Returns:
- the instance
-
-