Package io.jenetics.stat
Class IntSummary
- java.lang.Object
-
- io.jenetics.stat.IntSummary
-
- All Implemented Interfaces:
Serializable
public final class IntSummary extends Object implements Serializable
Value objects which contains statistical summary information.- Since:
- 3.0
- Version:
- 6.0
- See Also:
IntSummaryStatistics
, Serialized Form- Implementation Note:
- This class is immutable and thread-safe.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
count()
Returns the count of values recorded.boolean
equals(Object obj)
int
hashCode()
int
max()
Return the maximum value recorded, orInteger.MIN_VALUE
if no values have been recorded.static int
max(int[] values)
Return the maximum value of the given double array.double
mean()
Return the arithmetic mean of values recorded, or zero if no values have been recorded.static double
mean(int[] values)
Returns a double describing the arithmetic mean of the values, orDouble.NaN
if thevalues
array is empty.int
min()
Return the minimum value recorded, orInteger.MAX_VALUE
if no values have been recorded.static int
min(int[] values)
Return the minimum value of the given double array.static IntSummary
of(long count, int min, int max, long sum, double mean)
Create an immutable object which contains statistical summary values.static IntSummary
of(IntSummaryStatistics statistics)
Return a new value object of the statistical summary, currently represented by thestatistics
object.long
sum()
Return the sum of values recorded, or zero if no values have been recorded.static long
sum(int[] values)
Return the sum of the given double array.static <T> Collector<T,?,IntSummary>
toIntSummary(ToIntFunction<? super T> mapper)
Return aCollector
which applies an int-producing mapping function to each input element, and returns summary-statistics for the resulting values.String
toString()
-
-
-
Method Detail
-
count
public long count()
Returns the count of values recorded.- Returns:
- the count of recorded values
-
min
public int min()
Return the minimum value recorded, orInteger.MAX_VALUE
if no values have been recorded.- Returns:
- the minimum value, or
Integer.MAX_VALUE
if none
-
max
public int max()
Return the maximum value recorded, orInteger.MIN_VALUE
if no values have been recorded.- Returns:
- the maximum value, or
Integer.MIN_VALUE
if none
-
sum
public long sum()
Return the sum of values recorded, or zero if no values have been recorded.- Returns:
- the sum of values, or zero if none
-
mean
public double mean()
Return the arithmetic mean of values recorded, or zero if no values have been recorded.- Returns:
- the arithmetic mean of values, or zero if none
-
of
public static IntSummary of(long count, int min, int max, long sum, double mean)
Create an immutable object which contains statistical summary values.- Parameters:
count
- the count of values recordedmin
- the minimum valuemax
- the maximum valuesum
- the sum of the recorded valuesmean
- the arithmetic mean of values- Returns:
- an immutable object which contains statistical values
-
of
public static IntSummary of(IntSummaryStatistics statistics)
Return a new value object of the statistical summary, currently represented by thestatistics
object.- Parameters:
statistics
- the creating (mutable) statistics class- Returns:
- the statistical moments
-
toIntSummary
public static <T> Collector<T,?,IntSummary> toIntSummary(ToIntFunction<? super T> mapper)
Return aCollector
which applies an int-producing mapping function to each input element, and returns summary-statistics for the resulting values.final Stream<SomeObject> stream = ... final IntSummary summary = stream .collect(toIntSummary(v -> v.intValue()));
- Type Parameters:
T
- the type of the input elements- Parameters:
mapper
- a mapping function to apply to each element- Returns:
- a
Collector
implementing the summary-statistics reduction - Throws:
NullPointerException
- if the givenmapper
isnull
-
min
public static int min(int[] values)
Return the minimum value of the given double array.- Parameters:
values
- the array.- Returns:
- the minimum value or
Integer.MAX_VALUE
if the given array is empty. - Throws:
NullPointerException
- if the given array isnull
.- Since:
- 4.0
-
max
public static int max(int[] values)
Return the maximum value of the given double array.- Parameters:
values
- the array.- Returns:
- the maximum value or
Integer.MIN_VALUE
if the given array is empty. - Throws:
NullPointerException
- if the given array isnull
.- Since:
- 4.0
-
sum
public static long sum(int[] values)
Return the sum of the given double array.- Parameters:
values
- the values to sum up.- Returns:
- the sum of the given
values
. - Throws:
NullPointerException
- if the given array isnull
.- Since:
- 4.0
-
mean
public static double mean(int[] values)
Returns a double describing the arithmetic mean of the values, orDouble.NaN
if thevalues
array is empty.- Parameters:
values
- the values to calculate the mean of- Returns:
- the arithmetic mean of the given
values
orDouble.NaN
if thevalues
array is empty - Throws:
NullPointerException
- if the given array isnull
.- Since:
- 4.0
-
-