Class IntStatistics.Builder
java.lang.Object
org.apache.commons.statistics.descriptive.IntStatistics.Builder
- Enclosing class:
IntStatistics
A builder for
IntStatistics.- Since:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StatisticsConfigurationConfiguration options for computation of statistics.private RangeFunction<int[], IntMax> TheIntMaxconstructor.private RangeFunction<int[], IntMin> TheIntMinconstructor.private RangeFunction<int[], FirstMoment> The moment constructor.private intThe order of the moment.private static final int[]An empty double array.private RangeFunction<int[], Product> TheProductconstructor.private RangeFunction<int[], IntSum> TheIntSumconstructor.private RangeFunction<int[], SumOfLogs> TheSumOfLogsconstructor.private RangeFunction<int[], IntSumOfSquares> TheIntSumOfSquaresconstructor. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) IntStatistics.BuilderAdd the statistic to the statistics to compute.build()Builds anIntStatisticsinstance.build(int... values) Builds anIntStatisticsinstance using the inputvalues.build(int[] values, int from, int to) Builds anIntStatisticsinstance using the specified range ofvalues.private IntStatisticscreate(int[] values, int from, int to) Builds anIntStatisticsinstance using the inputvalues.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 int[] NO_VALUESAn empty double array. -
min
TheIntMinconstructor. -
max
TheIntMaxconstructor. -
moment
The moment constructor. May return any instance ofFirstMoment. -
sum
TheIntSumconstructor. -
product
TheProductconstructor. -
sumOfSquares
TheIntSumOfSquaresconstructor. -
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=3 is sum of cubed 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
-
build
Builds anIntStatisticsinstance using the inputvalues.Note:
IntStatisticscomputed usingacceptmay be different from this instance.- Parameters:
values- Values.- Returns:
IntStatisticsinstance.
-
build
Builds anIntStatisticsinstance using the specified range ofvalues.Note:
IntStatisticscomputed usingacceptmay be different from this instance.- Parameters:
values- Values.from- Inclusive start of the range.to- Exclusive end of the range.- Returns:
IntStatisticsinstance.- Throws:
IndexOutOfBoundsException- if the sub-range is out of bounds- Since:
- 1.2
-
create
Builds anIntStatisticsinstance using the inputvalues.Note:
IntStatisticscomputed 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:
IntStatisticsinstance.
-
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
-