Package io.jenetics.stat
Class DoubleMoments
- java.lang.Object
-
- io.jenetics.stat.DoubleMoments
-
- All Implemented Interfaces:
Serializable
public final class DoubleMoments extends Object implements Serializable
Value objects which contains statistical moments.- Since:
- 3.0
- Version:
- 6.0
- Author:
- Franz Wilhelmstötter
- See Also:
DoubleMomentStatistics
, 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.double
max()
Return the maximum value recorded, orDouble.NEGATIVE_INFINITY
if no values have been recorded.double
mean()
Return the arithmetic mean of values recorded, or zero if no values have been recorded.double
min()
Return the minimum value recorded, orDouble.POSITIVE_INFINITY
if no values have been recorded.static DoubleMoments
of(long count, double min, double max, double sum, double mean, double variance, double skewness, double kurtosis)
Create an immutable object which contains statistical values.static DoubleMoments
of(DoubleMomentStatistics 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.double
sum()
Return the sum of values recorded, or zero if no values have been recorded.static <N extends Number>
Collector<N,?,DoubleMoments>toDoubleMoments()
Return aCollector
which returns moments-statistics for the resulting values.static <T> Collector<T,?,DoubleMoments>
toDoubleMoments(ToDoubleFunction<? super T> mapper)
Return aCollector
which applies an double-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 double min()
Return the minimum value recorded, orDouble.POSITIVE_INFINITY
if no values have been recorded.- Returns:
- the minimum value, or
Integer.MAX_VALUE
if none
-
max
public double max()
Return the maximum value recorded, orDouble.NEGATIVE_INFINITY
if no values have been recorded.- Returns:
- the maximum value, or
Integer.MIN_VALUE
if none
-
sum
public double 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 DoubleMoments of(long count, double min, double max, double 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 DoubleMoments of(DoubleMomentStatistics 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
-
toDoubleMoments
public static <N extends Number> Collector<N,?,DoubleMoments> toDoubleMoments()
Return aCollector
which returns moments-statistics for the resulting values.final Stream<Double> stream = ... final DoubleMoments moments = stream.collect(toDoubleMoments()));
- Type Parameters:
N
- the type of the input elements- Returns:
- a
Collector
implementing the moments-statistics reduction - Since:
- 4.1
-
toDoubleMoments
public static <T> Collector<T,?,DoubleMoments> toDoubleMoments(ToDoubleFunction<? super T> mapper)
Return aCollector
which applies an double-producing mapping function to each input element, and returns moments-statistics for the resulting values.final Stream<SomeObject> stream = ... final DoubleMoments moments = stream .collect(toDoubleMoments(v -> v.doubleValue()));
- 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
-
-