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 Statistics
Statistics about the differences between consecutive sample values.private double
private long
Last value given to anaccept(long)
method as along
, or 0 if none.private static final long
Serial number for compatibility with different versions. -
Constructor Summary
ConstructorsConstructorDescriptionWithDelta
(CharSequence name, Statistics delta) Constructs an initially empty set of statistics using the specified object fordelta
statistics. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(double sample) Updates statistics for the specified sample value and its discrete derivatives.void
accept
(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.void
combine
(Statistics stats) Update statistics with all samples from the specifiedstats
.(package private) final void
Decrements the count of NaN values by one.Returns the statistics about difference between consecutive values.boolean
Tests this statistics with the specified object for equality.int
hashCode()
Returns a hash code value for this statistics.void
reset()
Resets this object state as if it was just created.void
scale
(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, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.function.DoubleConsumer
andThen
Methods 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 fordelta
statistics. 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 ofStatistics
object 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:
reset
in classStatistics
-
accept
public void accept(double sample) Updates statistics for the specified sample value and its discrete derivatives. Thedelta
statistics are updated withsample - samplelast
value, wheresamplelast
is the value given to the previous call of anaccept(…)
method.- Specified by:
accept
in interfaceDoubleConsumer
- Overrides:
accept
in 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:
accept
in interfaceLongConsumer
- Overrides:
accept
in classStatistics
- Parameters:
sample
- the sample value.- See Also:
-
combine
Update statistics with all samples from the specifiedstats
.- Overrides:
combine
in classStatistics
- Parameters:
stats
- the statistics to be added tothis
.- Throws:
ClassCastException
- ifstats
is not an instance ofStatistics.Delta
.
-
scale
public void scale(double factor) Scales the statistics by the given factor.- Overrides:
scale
in 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:
decrementCountNaN
in classStatistics
-
differences
Returns the statistics about difference between consecutive values.- Overrides:
differences
in classStatistics
- Returns:
- the statistics on the differences between consecutive sample values,
or
null
if not calculated by this object. - See Also:
-
clone
Returns a clone of this statistics.- Overrides:
clone
in classStatistics
- Returns:
- a clone of this statistics.
-
equals
Tests this statistics with the specified object for equality.- Overrides:
equals
in classStatistics
- Parameters:
obj
- the object to compare with.- Returns:
true
if both objects are equal.
-
hashCode
public int hashCode()Returns a hash code value for this statistics.- Overrides:
hashCode
in classStatistics
-