Class IntStatistics.Builder
- java.lang.Object
-
- org.apache.commons.statistics.descriptive.IntStatistics.Builder
-
- Enclosing class:
- IntStatistics
public static final class IntStatistics.Builder extends java.lang.ObjectA builder forIntStatistics.
-
-
Field Summary
Fields Modifier and Type Field Description private StatisticsConfigurationconfigConfiguration options for computation of statistics.private RangeFunction<int[],IntMax>maxTheIntMaxconstructor.private RangeFunction<int[],IntMin>minTheIntMinconstructor.private RangeFunction<int[],FirstMoment>momentThe moment constructor.private intmomentOrderThe order of the moment.private static int[]NO_VALUESAn empty double array.private RangeFunction<int[],Product>productTheProductconstructor.private RangeFunction<int[],IntSum>sumTheIntSumconstructor.private RangeFunction<int[],SumOfLogs>sumOfLogsTheSumOfLogsconstructor.private RangeFunction<int[],IntSumOfSquares>sumOfSquaresTheIntSumOfSquaresconstructor.
-
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) IntStatistics.Builderadd(Statistic statistic)Add the statistic to the statistics to compute.IntStatisticsbuild()Builds anIntStatisticsinstance.IntStatisticsbuild(int... values)Builds anIntStatisticsinstance using the inputvalues.IntStatisticsbuild(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>
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.IntStatistics.BuildersetConfiguration(StatisticsConfiguration v)Sets the statistics configuration options for computation of statistics.
-
-
-
Field Detail
-
NO_VALUES
private static final int[] NO_VALUES
An empty double array.
-
min
private RangeFunction<int[],IntMin> min
TheIntMinconstructor.
-
max
private RangeFunction<int[],IntMax> max
TheIntMaxconstructor.
-
moment
private RangeFunction<int[],FirstMoment> moment
The moment constructor. May return any instance ofFirstMoment.
-
sum
private RangeFunction<int[],IntSum> sum
TheIntSumconstructor.
-
product
private RangeFunction<int[],Product> product
TheProductconstructor.
-
sumOfSquares
private RangeFunction<int[],IntSumOfSquares> sumOfSquares
TheIntSumOfSquaresconstructor.
-
sumOfLogs
private RangeFunction<int[],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
IntStatistics.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=3 is sum of cubed deviations.- Parameters:
order- Order.
-
setConfiguration
public IntStatistics.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 IntStatistics build()
Builds anIntStatisticsinstance.- Returns:
IntStatisticsinstance.
-
build
public IntStatistics build(int... values)
Builds anIntStatisticsinstance using the inputvalues.Note:
IntStatisticscomputed usingacceptmay be different from this instance.- Parameters:
values- Values.- Returns:
IntStatisticsinstance.
-
build
public IntStatistics build(int[] values, int from, int to)
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:
java.lang.IndexOutOfBoundsException- if the sub-range is out of bounds- Since:
- 1.2
-
create
private IntStatistics create(int[] values, int from, int to)
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
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
-
-