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

private static final class Statistics.WithDelta extends 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 Details

    • serialVersionUID

      private static final long serialVersionUID
      Serial number for compatibility with different versions.
      See Also:
    • delta

      private Statistics delta
      Statistics about the differences between consecutive sample values. Consider this field as final; it is modified only by the clone() method.
    • last

      private double last
      Last value given to an accept(double) method as a double, or Double.NaN if none.
    • lastAsLong

      private long lastAsLong
      Last value given to an accept(long) method as a long, or 0 if none.
  • Constructor Details

    • WithDelta

      WithDelta(CharSequence name, Statistics delta)
      Constructs an initially empty set of statistics using the specified object for delta 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 of Statistics object could be chained as well.
      Parameters:
      name - the phenomenon for which this object is collecting statistics, or null.
      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 class Statistics
    • accept

      public void accept(double sample)
      Updates statistics for the specified sample value and its discrete derivatives. The delta statistics are updated with sample - samplelast value, where samplelast is the value given to the previous call of an accept(…) method.
      Specified by:
      accept in interface DoubleConsumer
      Overrides:
      accept in class Statistics
      Parameters:
      sample - the sample value (may be NaN).
      See Also:
    • accept

      public void accept(long sample)
      Performs the same work than accept(double), but with greater precision for very large integer values (greater than 252 in magnitude),
      Specified by:
      accept in interface LongConsumer
      Overrides:
      accept in class Statistics
      Parameters:
      sample - the sample value.
      See Also:
    • combine

      public void combine(Statistics stats) throws ClassCastException
      Update statistics with all samples from the specified stats.
      Overrides:
      combine in class Statistics
      Parameters:
      stats - the statistics to be added to this.
      Throws:
      ClassCastException - if stats is not an instance of Statistics.Delta.
    • scale

      public void scale(double factor)
      Scales the statistics by the given factor.
      Overrides:
      scale in class Statistics
      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 on reset() 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 class Statistics
    • differences

      public Statistics differences()
      Returns the statistics about difference between consecutive values.
      Overrides:
      differences in class Statistics
      Returns:
      the statistics on the differences between consecutive sample values, or null if not calculated by this object.
      See Also:
    • clone

      public Statistics clone()
      Returns a clone of this statistics.
      Overrides:
      clone in class Statistics
      Returns:
      a clone of this statistics.
    • equals

      public boolean equals(Object obj)
      Tests this statistics with the specified object for equality.
      Overrides:
      equals in class Statistics
      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 class Statistics