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.ObjectA builder forDoubleStatistics.
-
-
Field Summary
Fields Modifier and Type Field Description private StatisticsConfigurationconfigConfiguration options for computation of statistics.private RangeFunction<double[],Max>maxTheMaxconstructor.private RangeFunction<double[],Min>minTheMinconstructor.private RangeBiFunction<org.apache.commons.numbers.core.Sum,double[],FirstMoment>momentThe moment constructor.private intmomentOrderThe order of the moment.private static double[]NO_VALUESAn empty double array.private RangeFunction<double[],Product>productTheProductconstructor.private java.util.function.Function<org.apache.commons.numbers.core.Sum,Sum>sumTheSumconstructor.private RangeFunction<double[],SumOfLogs>sumOfLogsTheSumOfLogsconstructor.private RangeFunction<double[],SumOfSquares>sumOfSquaresTheSumOfSquaresconstructor.
-
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.Builderadd(Statistic statistic)Add the statistic to the statistics to compute.DoubleStatisticsbuild()Builds aDoubleStatisticsinstance.DoubleStatisticsbuild(double... values)Builds aDoubleStatisticsinstance using the inputvalues.DoubleStatisticsbuild(double[] values, int from, int to)Builds aDoubleStatisticsinstance using the specified range ofvalues.private DoubleStatisticscreate(double[] values, int from, int to)Builds aDoubleStatisticsinstance using the inputvalues.private static <S,T>
Tcreate(java.util.function.Function<S,T> constructor, S values)Creates the object from thevalues.private static <R,S,T>
Tcreate(RangeBiFunction<R,S,T> constructor, R r, S s, int from, int to)Creates the object from the valuesrands.private static <S,T>
Tcreate(RangeFunction<S,T> constructor, S values, int from, int to)Creates the object from thevalues.private voidcreateMoment(int order)Creates the moment constructor for the specifiedorder, e.g.DoubleStatistics.BuildersetConfiguration(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.
-
min
private RangeFunction<double[],Min> min
TheMinconstructor.
-
max
private RangeFunction<double[],Max> max
TheMaxconstructor.
-
moment
private RangeBiFunction<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
TheSumconstructor.
-
product
private RangeFunction<double[],Product> product
TheProductconstructor.
-
sumOfSquares
private RangeFunction<double[],SumOfSquares> sumOfSquares
TheSumOfSquaresconstructor.
-
sumOfLogs
private RangeFunction<double[],SumOfLogs> sumOfLogs
TheSumOfLogsconstructor.
-
momentOrder
private int momentOrder
The order of the moment. It corresponds to the power computed by theFirstMomentinstance 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:
thisinstance
-
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 aDoubleStatisticsinstance.- Returns:
DoubleStatisticsinstance.
-
build
public DoubleStatistics build(double... values)
Builds aDoubleStatisticsinstance using the inputvalues.Note:
DoubleStatisticscomputed usingacceptmay be different from this instance.- Parameters:
values- Values.- Returns:
DoubleStatisticsinstance.
-
build
public DoubleStatistics build(double[] values, int from, int to)
Builds aDoubleStatisticsinstance using the specified range ofvalues.Note:
DoubleStatisticscomputed usingacceptmay be different from this instance.- Parameters:
values- Values.from- Inclusive start of the range.to- Exclusive end of the range.- Returns:
DoubleStatisticsinstance.- Throws:
java.lang.IndexOutOfBoundsException- if the sub-range is out of bounds- Since:
- 1.2
-
create
private DoubleStatistics create(double[] values, int from, int to)
Builds aDoubleStatisticsinstance using the inputvalues.Note:
DoubleStatisticscomputed usingacceptmay be different from this instance.Warning: No range checks are performed.
- Parameters:
values- Values.from- Inclusive start of the range.to- Exclusive end of the range.- Returns:
DoubleStatisticsinstance.
-
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 <S,T> T create(RangeFunction<S,T> constructor, S values, int from, int to)
Creates the object from thevalues.- Type Parameters:
S- value typeT- object type- Parameters:
constructor- Constructor.values- Valuesfrom- Inclusive start of the range.to- Exclusive end of the range.- Returns:
- the instance
-
create
private static <R,S,T> T create(RangeBiFunction<R,S,T> constructor, R r, S s, int from, int to)
Creates the object from the valuesrands.- Type Parameters:
R- value typeS- value typeT- object type- Parameters:
constructor- Constructor.r- Value.s- Value.from- Inclusive start of the range.to- Exclusive end of the range.- Returns:
- the instance
-
-