Package io.jenetics.stat
Class IntMoments
- java.lang.Object
-
- io.jenetics.stat.IntMoments
-
- All Implemented Interfaces:
Serializable
public final class IntMoments extends Object implements Serializable
Value objects which contains statistical moments.- Since:
- 3.0
- Version:
- 6.0
- See Also:
IntMomentStatistics
, 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()
double
kurtosis()
Return the kurtosis of values recorded, orDouble.NaN
if less than four values have been recorded.int
max()
Return the maximum value recorded, orInteger.MIN_VALUE
if no values have been recorded.double
mean()
Return the arithmetic mean of values recorded, or zero if no values have been recorded.int
min()
Return the minimum value recorded, orInteger.MAX_VALUE
if no values have been recorded.static IntMoments
of(long count, int min, int max, long sum, double mean, double variance, double skewness, double kurtosis)
Create an immutable object which contains statistical values.static IntMoments
of(IntMomentStatistics statistics)
Return a new value object of the statistical moments, currently represented by thestatistics
object.double
skewness()
Return the skewness of values recorded, orDouble.NaN
if less than two values have been recorded.long
sum()
Return the sum of values recorded, or zero if no values have been recorded.static <N extends Number>
Collector<N,?,IntMoments>toIntMoments()
Return aCollector
which returns moments-statistics for the resulting values.static <T> Collector<T,?,IntMoments>
toIntMoments(ToIntFunction<? super T> mapper)
Return aCollector
which applies an int-producing mapping function to each input element, and returns moments-statistics for the resulting values.String
toString()
double
variance()
Return the variance of values recorded, orDouble.NaN
if no values have been recorded.
-
-
-
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
-
variance
public double variance()
Return the variance of values recorded, orDouble.NaN
if no values have been recorded.- Returns:
- the variance of values, or
NaN
if none
-
skewness
public double skewness()
Return the skewness of values recorded, orDouble.NaN
if less than two values have been recorded.- Returns:
- the skewness of values, or
NaN
if less than two values have been recorded - See Also:
- Skewness
-
kurtosis
public double kurtosis()
Return the kurtosis of values recorded, orDouble.NaN
if less than four values have been recorded.- Returns:
- the kurtosis of values, or
NaN
if less than four values have been recorded - See Also:
- Kurtosis
-
of
public static IntMoments of(long count, int min, int max, long sum, double mean, double variance, double skewness, double kurtosis)
Create an immutable object which contains statistical values.- Parameters:
count
- the count of values recordedmin
- the minimum valuemax
- the maximum valuesum
- the sum of the recorded valuesmean
- the arithmetic mean of valuesvariance
- the variance of valuesskewness
- the skewness of valueskurtosis
- the kurtosis of values- Returns:
- an immutable object which contains statistical values
-
of
public static IntMoments of(IntMomentStatistics statistics)
Return a new value object of the statistical moments, currently represented by thestatistics
object.- Parameters:
statistics
- the creating (mutable) statistics class- Returns:
- the statistical moments
-
toIntMoments
public static <N extends Number> Collector<N,?,IntMoments> toIntMoments()
Return aCollector
which returns moments-statistics for the resulting values.final Stream<Integer> stream = ... final IntMoments moments = stream.collect(toIntMoments()));
- Type Parameters:
N
- the type of the input elements- Returns:
- a
Collector
implementing the moments-statistics reduction - Since:
- 4.1
-
toIntMoments
public static <T> Collector<T,?,IntMoments> toIntMoments(ToIntFunction<? super T> mapper)
Return aCollector
which applies an int-producing mapping function to each input element, and returns moments-statistics for the resulting values.final Stream<SomeObject> stream = ... final IntMoments moments = stream .collect(toIntMoments(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 moments-statistics reduction - Throws:
NullPointerException
- if the givenmapper
isnull
-
-