Package org.apache.sis.math
Class Statistics.WithDelta
java.lang.Object
org.apache.sis.math.Statistics
org.apache.sis.math.Statistics.WithDelta
- All Implemented Interfaces:
Serializable,Cloneable,DoubleConsumer,LongConsumer
- Enclosing class:
- Statistics
Holds some statistics about the difference between consecutive sample values.
Given a series of s₀, s₁, s₂, s₃,
etc… samples, this class computes statistics for s₁-s₀,
s₂-s₁, s₃-s₂, etc…
which are stored in a
delta statistics object.- Since:
- 0.3
- Version:
- 0.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StatisticsStatistics about the differences between consecutive sample values.private doubleprivate longLast value given to anaccept(long)method as along, or 0 if none.private static final longSerial number for compatibility with different versions. -
Constructor Summary
ConstructorsConstructorDescriptionWithDelta(CharSequence name, Statistics delta) Constructs an initially empty set of statistics using the specified object fordeltastatistics. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(double sample) Updates statistics for the specified sample value and its discrete derivatives.voidaccept(long sample) Performs the same work thanaccept(double), but with greater precision for very large integer values (greater than 252 in magnitude),clone()Returns a clone of this statistics.voidcombine(Statistics stats) Update statistics with all samples from the specifiedstats.(package private) final voidDecrements the count of NaN values by one.Returns the statistics about difference between consecutive values.booleanTests this statistics with the specified object for equality.inthashCode()Returns a hash code value for this statistics.voidreset()Resets this object state as if it was just created.voidscale(double factor) Scales the statistics by the given factor.Methods inherited from class org.apache.sis.math.Statistics
count, countNaN, forSeries, maximum, mean, minimum, name, rms, span, standardDeviation, sum, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.function.DoubleConsumer
andThenMethods inherited from interface java.util.function.LongConsumer
andThen
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for compatibility with different versions.- See Also:
-
delta
Statistics about the differences between consecutive sample values. Consider this field as final; it is modified only by theclone()method. -
last
private double last -
lastAsLong
private long lastAsLongLast value given to anaccept(long)method as along, or 0 if none.
-
-
Constructor Details
-
WithDelta
WithDelta(CharSequence name, Statistics delta) Constructs an initially empty set of statistics using the specified object fordeltastatistics. This constructor allows chaining different kind of statistics objects. For example, one could write: which would compute statistics of sample values, statistics of difference between consecutive sample values, and statistics of difference of difference between consecutive sample values. Other kinds ofStatisticsobject could be chained as well.- Parameters:
name- the phenomenon for which this object is collecting statistics, ornull.delta- the object where to stores delta statistics.
-
-
Method Details
-
reset
public void reset()Resets this object state as if it was just created.- Overrides:
resetin classStatistics
-
accept
public void accept(double sample) Updates statistics for the specified sample value and its discrete derivatives. Thedeltastatistics are updated withsample - samplelastvalue, wheresamplelastis the value given to the previous call of anaccept(…)method.- Specified by:
acceptin interfaceDoubleConsumer- Overrides:
acceptin classStatistics- Parameters:
sample- the sample value (may be NaN).- See Also:
-
accept
public void accept(long sample) Performs the same work thanaccept(double), but with greater precision for very large integer values (greater than 252 in magnitude),- Specified by:
acceptin interfaceLongConsumer- Overrides:
acceptin classStatistics- Parameters:
sample- the sample value.- See Also:
-
combine
Update statistics with all samples from the specifiedstats.- Overrides:
combinein classStatistics- Parameters:
stats- the statistics to be added tothis.- Throws:
ClassCastException- ifstatsis not an instance ofStatistics.Delta.
-
scale
public void scale(double factor) Scales the statistics by the given factor.- Overrides:
scalein classStatistics- Parameters:
factor- the factor by which to multiply the statistics.
-
decrementCountNaN
final void decrementCountNaN()Decrements the count of NaN values by one. This method is invoked on construction or onreset()call, because the first discrete derivative always have one less value than the original one, the second derivative two less values, etc.- Overrides:
decrementCountNaNin classStatistics
-
differences
Returns the statistics about difference between consecutive values.- Overrides:
differencesin classStatistics- Returns:
- the statistics on the differences between consecutive sample values,
or
nullif not calculated by this object. - See Also:
-
clone
Returns a clone of this statistics.- Overrides:
clonein classStatistics- Returns:
- a clone of this statistics.
-
equals
Tests this statistics with the specified object for equality.- Overrides:
equalsin classStatistics- Parameters:
obj- the object to compare with.- Returns:
trueif both objects are equal.
-
hashCode
public int hashCode()Returns a hash code value for this statistics.- Overrides:
hashCodein classStatistics
-