Class DoubleStatistics.Builder
- java.lang.Object
-
- org.apache.commons.statistics.descriptive.DoubleStatistics.Builder
-
- Enclosing class:
- DoubleStatistics
public static final class DoubleStatistics.Builder extends java.lang.Object
A builder forDoubleStatistics
.
-
-
Field Summary
Fields Modifier and Type Field Description private StatisticsConfiguration
config
Configuration options for computation of statistics.private java.util.function.Function<double[],Max>
max
TheMax
constructor.private java.util.function.Function<double[],Min>
min
TheMin
constructor.private java.util.function.BiFunction<org.apache.commons.numbers.core.Sum,double[],FirstMoment>
moment
The moment constructor.private int
momentOrder
The order of the moment.private static double[]
NO_VALUES
An empty double array.private java.util.function.Function<double[],Product>
product
TheProduct
constructor.private java.util.function.Function<org.apache.commons.numbers.core.Sum,Sum>
sum
TheSum
constructor.private java.util.function.Function<double[],SumOfLogs>
sumOfLogs
TheSumOfLogs
constructor.private java.util.function.Function<double[],SumOfSquares>
sumOfSquares
TheSumOfSquares
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) DoubleStatistics.Builder
add(Statistic statistic)
Add the statistic to the statistics to compute.DoubleStatistics
build()
Builds aDoubleStatistics
instance.DoubleStatistics
build(double... values)
Builds aDoubleStatistics
instance using the inputvalues
.private static <R,S,T>
Tcreate(java.util.function.BiFunction<R,S,T> constructor, R r, S s)
Creates the object from the valuesr
ands
.private static <S,T>
Tcreate(java.util.function.Function<S,T> constructor, S values)
Creates the object from thevalues
.private void
createMoment(int order)
Creates the moment constructor for the specifiedorder
, e.g.DoubleStatistics.Builder
setConfiguration(StatisticsConfiguration v)
Sets the statistics configuration options for computation of statistics.
-
-
-
Field Detail
-
NO_VALUES
private static final double[] NO_VALUES
An empty double array.
-
moment
private java.util.function.BiFunction<org.apache.commons.numbers.core.Sum,double[],FirstMoment> moment
The moment constructor. May return any instance ofFirstMoment
.
-
sum
private java.util.function.Function<org.apache.commons.numbers.core.Sum,Sum> sum
TheSum
constructor.
-
sumOfSquares
private java.util.function.Function<double[],SumOfSquares> sumOfSquares
TheSumOfSquares
constructor.
-
sumOfLogs
private java.util.function.Function<double[],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
DoubleStatistics.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=2 is sum of squared deviations.- Parameters:
order
- Order.
-
setConfiguration
public DoubleStatistics.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 DoubleStatistics build()
Builds aDoubleStatistics
instance.- Returns:
DoubleStatistics
instance.
-
build
public DoubleStatistics build(double... values)
Builds aDoubleStatistics
instance using the inputvalues
.Note:
DoubleStatistics
computed usingaccept
may be different from this instance.- Parameters:
values
- Values.- Returns:
DoubleStatistics
instance.
-
create
private static <S,T> T create(java.util.function.Function<S,T> constructor, S values)
Creates the object from thevalues
.- Type Parameters:
S
- value typeT
- object type- Parameters:
constructor
- Constructor.values
- Values- Returns:
- the instance
-
create
private static <R,S,T> T create(java.util.function.BiFunction<R,S,T> constructor, R r, S s)
Creates the object from the valuesr
ands
.- Type Parameters:
R
- value typeS
- value typeT
- object type- Parameters:
constructor
- Constructor.r
- Value.s
- Value.- Returns:
- the instance
-
-