Class DoubleStatistics.Builder
java.lang.Object
org.apache.commons.statistics.descriptive.DoubleStatistics.Builder
- Enclosing class:
DoubleStatistics
A builder for
DoubleStatistics.- Since:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StatisticsConfigurationConfiguration options for computation of statistics.private RangeFunction<double[], Max> TheMaxconstructor.private RangeFunction<double[], Min> TheMinconstructor.private RangeBiFunction<org.apache.commons.numbers.core.Sum, double[], FirstMoment> The moment constructor.private intThe order of the moment.private static final double[]An empty double array.private RangeFunction<double[], Product> TheProductconstructor.TheSumconstructor.private RangeFunction<double[], SumOfLogs> TheSumOfLogsconstructor.private RangeFunction<double[], SumOfSquares> TheSumOfSquaresconstructor. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) DoubleStatistics.BuilderAdd the statistic to the statistics to compute.build()Builds aDoubleStatisticsinstance.build(double... values) Builds aDoubleStatisticsinstance using the inputvalues.build(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> T Creates the object from thevalues.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.private static <S,T> T create(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.Sets the statistics configuration options for computation of statistics.
-
Field Details
-
NO_VALUES
private static final double[] NO_VALUESAn empty double array. -
min
TheMinconstructor. -
max
TheMaxconstructor. -
moment
The moment constructor. May return any instance ofFirstMoment. -
sum
-
product
TheProductconstructor. -
sumOfSquares
TheSumOfSquaresconstructor. -
sumOfLogs
TheSumOfLogsconstructor. -
momentOrder
private int momentOrderThe 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
Configuration options for computation of statistics.
-
-
Constructor Details
-
Builder
Builder()Create an instance.
-
-
Method Details
-
add
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
Sets the statistics configuration options for computation of statistics.- Parameters:
v- Value.- Returns:
- the builder
- Throws:
NullPointerException- if the value is null
-
build
Builds aDoubleStatisticsinstance.- Returns:
DoubleStatisticsinstance.
-
build
Builds aDoubleStatisticsinstance using the inputvalues.Note:
DoubleStatisticscomputed usingacceptmay be different from this instance.- Parameters:
values- Values.- Returns:
DoubleStatisticsinstance.
-
build
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:
IndexOutOfBoundsException- if the sub-range is out of bounds- Since:
- 1.2
-
create
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
Creates the object from thevalues.- Type Parameters:
S- value typeT- object type- Parameters:
constructor- Constructor.values- Values- Returns:
- the instance
-
create
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
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
-